The Ajax method of jquery, the use of return in success, the end of the program, the end is only success this method, that is, success in the scope of return is only success;
If you want to use return to end the entire JS function in success, it is best to define a global variable in the outermost method body, var Isover = True, and Isover to False if the condition is met in success
In the Ajax method outside the body through the global variable Isover value to determine whether the JS function return,
At the same time also note: Ajax method Async:false, must be false;
function Mysubmit () {
Ajax verifies whether the current agent can initiate an application
var hasprivileage = true;
$.ajax ({
URL: "Commitcheckforagent.action",
Data: {agentno:$ ("#agentNo"). Val ()},
Type: "Post",
Async:false,
Success:function (Result) {
if (result = = "Billauditing") {
Alert ("The merchant has a billing change order that is being audited and cannot be launched again!") ");
hasprivileage = false;
return hasprivileage;
}
},
Error:function (Result) {
Alert (' Error ... ');
}
});
if (!hasprivileage) {
return;
}
if ($ ("#agentNo"). Val () ==null | | $ ("#agentNo"). val () = = "") {
Alert ("Please enter the dealer number. ");
Return
}
if ($ ("#settleAccountType"). Val () ==null | | $ ("#settleAccountType"). val () = = "") {
Alert ("Account type cannot be empty.) ");
Return
}
if ($ ("#bankAccountName"). Val () ==null | | $ ("#bankAccountName"). val () = = "") {
Alert ("The bank account name cannot be empty.") ");
Return
}
if ($ ("#bankAccountNo"). Val () ==null | | $ ("#bankAccountNo"). val () = = "") {
Alert ("The bank account number cannot be empty.") ");
Return
}
if ($ ("#openBankName"). Val () ==null | | $ ("#openBankName"). val () = = "") {
Alert ("The name of the account bank cannot be empty. ");
Return
}
if ($ ("#province"). Val () ==null | | $ ("#province"). val () = = "") {
Alert ("The account-opening province cannot be empty. ");
Return
}
if ($ ("#city"). Val () ==null | | $ ("#city"). val () = = "") {
Alert ("The opening of the market cannot be empty. ");
Return
}
if ($ ("#file1"). Val () ==null | | $ ("#file1"). val () = = "") {
Alert ("Please upload the picture. ");
Return
}
var Customerno = $ ("#customerNo"). Val ()
$.ajax ({
Type: "Post",
Data:{customerno:customerno},
URL: "C005commitcheck.action",
Success:function (msg) {
if (msg = = "") {
$ ("#form1"). Submit ();
}else{
Alert (msg);
Window.location.href = window.location.href;
// }
// }
// });
}
Using return in success in the Ajax method of jquery