日期:2014-05-17  浏览次数:20653 次

jquery中ajax异步更新,val的问题
jquery中ajax异步更新,val的问题 。请高手求解:

从action更新过来的typecode、status值 ,alert()时都能出来正确的值,为什么对id=“typecode” 、id=“status”的文本框进行复制 就不行。难道是val的问题



$("#bid").change(function(){//下拉列表

$.post("BillAction.do?method=billByBid","id=" + $(this).val(),function(data){

alert($(data).find("typecode").text());
alert($(data).find("status").text());

$("#typecode").val($(data).find("typecode").text());
$("#status").val($(data).find("status").text());


});
});

------解决方案--------------------
不是val吧应该是text吧
------解决方案--------------------
有些标签没有value属性 就不能用val()函数
------解决方案--------------------
var typecodeval=$(data).find("typecode").text();
$("#typecode").val(typecodeval);
看看行不行这个2个得值的返回类型不一样 val有数组和字符串 text返回的好像是html类型的