1.ajax提交, 經過 url直接提交表單 ajax
$.ajax({
type: "post",
url: "/rechargeWithdrawalRecord/saveRecharge",
//把表單數據拿到,提交所有數據 json
data:$("form").serialize(),
dataType:"json",
success: function(data) {
if(data == 1){
layer.alert('充值單生成成功 !', {
icon: 1,
title: "提示"
}, function(index){
//do something
window.parent.closeLayer();
layer.close(index);
}
);async
2.submit提交表單 , url 進行表單驗證, submit 進行表單提交post
$.ajax({
type: "post",
cache: false,
url: "${ctx}/account/accountCheckRepetition",
data:{ditchAccountName:ditchAccountName, ditchAccount:ditchAccount, ditchId:ditchId},
dataType:"json",
async:false,
success: function(data) {
//alert(data);
if (data==3) {
layer.msg("帳戶名稱和渠道帳戶都存在,請從新輸入", {icon:0});
return;
} else if (data==1) {
layer.msg("帳戶名稱存在,請從新輸入", {icon:0});
return;
} else if (data==2) {
layer.msg("渠道帳戶存在,請從新輸入", {icon:0});
return;
} else {
$("#saveAccountFrom").submit();
}
}
});
}url