form表單提交Ajax請求后不跳轉





form.on('submit(demo1)', function (data) {
// var param = data.field;//定義臨時變量獲取表單提交過來的數據,非json格式

console.log($(data.form).serialize());//測試是否獲取到表單數據,調試模式下在頁面控制台查看
$.ajax({
url: "customer/updateOtherUserSubmit",
//type: 'post',//method請求方式,get或者post
dataType: 'json',//預期服務器返回的數據類型
data: $(data.form).serialize(),//表格數據序列化
// contentType: "application/json; charset=utf-8",
success: function (res) {//res為相應體,function為回調函數
if (res.code == '200') {
//$("#res").click();//調用重置按鈕將表單數據清空
window.location.href='customer/customerList?menuId=5&viewPath=customer/customerList';
} else {
layer.alert(data.msg, {icon: 5});
}
},
error: function () {
layer.alert('操作失敗!!!', {icon: 5});
}
});
//return false;
event.preventDefault() //阻止form表單默認提交
});//end form


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM