Jquery ajax 数据更新

$(function(){
var $personWifePs=$("#wife-money tbody tr");
var $personWife=$("#wife-money").find("input.write");
var $val=null;
$.ajax({
type: "POST",
url: "data/hm_monery_serceh.php",
success: function(dtmonery){
var $list = JSON.parse(dtmonery);
for(info in $list) {
$personWifePs.append(`<td>
<input id="d${n+=1}" value="${$list[info].monery}" class="write" type="text"/>
</td>`)
$personWife.val($list[info].monery);
}
}
});
$personWifePs.on("change",".write",function(){
var $iput=$(this);
$val=$(this).val();
var $index=$personWifePs.children().find("input").index($(this)[0]);
$.ajax({
type: "POST",
url: "data/hm_monery_update.php",
data: "id="+($index+1)+"&monery="+$val,
success: function(dtmonery){
var $listone = JSON.parse(dtmonery);
$iput.val($listone.monery);
}
});
});
});
posted @ 2017-08-15 17:56  ThisCall  阅读(741)  评论(0编辑  收藏  举报