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);
}
});
});
});
原文地址:https://www.cnblogs.com/dianzan/p/7366490.html