jqtransform不改变从阿贾克斯获得的值 [英] jqtransform don't transform the values received from ajax
问题描述
我有这样的Java脚本:
i have this java script:
$("#judet div.jqTransformSelectWrapper ul li a").click(function(){
var jud= $("#judetul1").val();
$.ajax({
type: "POST",
url: "rental/cms/inc/ajax/cities.php",
data: { 'jud': jud },
success: function (msg) {
$("#oras1").html(msg);
},
error: function (xhr, err) {
alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
alert("responseText: " + xhr.responseText);
}
});
});
和这个网站:
<div class=" h">
<span class="block">Orasul</span>
<div class="select6" id="oras">
<select name="oras1" id="oras1" onchange="zone1();sectorul();">
</select>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
和这个PHP:
public function get_oras($code3) {
echo "<option selected='selected' value='0'>Alege oras</option>";
$code='PPLA';
$code2='PPLA2';
$sql="SELECT * FROM `locatii` WHERE (`feature_code`=:code OR `feature_code`=:code2) AND `admin1_code`=:code3 ORDER BY `asciiname` ASC";
$stmt = $this->dbh->prepare($sql);
$stmt->bindParam(':code', $code, PDO::PARAM_STR, 30);
$stmt->bindParam(':code2', $code2, PDO::PARAM_STR, 30);
$stmt->bindParam(':code3', $code3, PDO::PARAM_INT);
$stmt->execute();
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $result)
{
$oras[]="<option value='".$result['geonameid']."'>".$result['asciiname']."</option>";
}
return $oras;
}
HTML的JUDETUL:
html for judetul:
<div class=" h">
<span class="block">Judetul</span>
<div class="select6" id="judet">
<?php $judetul=$db->get_judet(); ?>
<select name="judetul1" id="judetul1" >
<option selected="selected">---</option>
<?php foreach ($judetul as $val=>$k) { ?>
<option value="<?php echo $val; ?>"><?php echo $k; ?></option>
<?php } ?>
</select>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
现在的问题是:
The problem is:
没有jqtransform脚本做工非常精细,但如果我有jqtransform不填充选择oras1的。 我认为这是一个问题,因为我变换一种形式,然后再我填充值......这样的值不会转化成我的oras1选择。
without the jqtransform the scripts work very fine, but if I include jqtransform the select oras1 is not populated. I think it's a problem because I transform a form first and then I populate with values...so that values will not be transformed into my oras1 select.
我该如何解决呢? 我可以改变选择后,我填充它与价值? 非常感谢!
How can I fix it? Can I transform the select after I populate it with values? Thanks a lot!
推荐答案
你的猜测是正确的,jqTransform转换为文档准备您的选择框。 jqTransform后,您所看到的外观上的选择框是一个包装。 因此,你的Ajax请求后,更新的选择的只是影响了隐藏select元素而不是包装。
Your guess is correct, the jqTransform transform your select box at document-ready. The appearance you see on select box after jqTransform is a wrapper. Therefore, the update in the select's after your ajax request is only affecting the hidden select element but not the wrapper.
您可以尝试重新jqTransfrom的选择框来得到它的权利。
You can try re-jqTransfrom the select box to get it right.
或者,请访问我的博客 http://infrahtml.blogspot.hk/2013/12/jstransform - 选择框,repopulation.html 以更改插件
Or, visit my blog http://infrahtml.blogspot.hk/2013/12/jstransform-select-box-repopulation.html to make changes to the plugins
这篇关于jqtransform不改变从阿贾克斯获得的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!