使用ajax異步請求的格式如下:
//先序列化所有參數,再通過ajax提交數據
var params = $.param({
'buycarid':othis.buycarid,
'actprice': $('#actprice').val(),
'numbers': $('#numbers').val(),
}, true);
$.ajax({
url: '/updatebuycar.action',//請求路徑
type: 'post',
data: params,//傳輸的數據
dataType: 'json',
success: function (data) {//返回值的處理
if (data === "0") {
layer.msg("更新成功");
window.location.href = '/admin/buycars/showbuycar?customerid='+othis.customerid;
}else {
layer.msg("更新失敗");
}
}
});