Ajax prevents automatic form submission and ajax prevents form submission
Override the form's checkForm method and use if and else To solve the problem of asynchronous judgment.
Function checkForm (){
1 var flag = false; 2 3 $. ajaxSetup ({async: false}); 4 5 $. post (<? Php echo "'". $ SITE_PHP. 'captchaajax. php'. "'";?>, 'Captcha = '+ document. getElementById ("captcha"). value, function (msg) {if (! ParseInt (msg) {layer. alert ('verification code error! ', {Time: 1000}); return flag;} else {6 7 $. post (<? Php echo "'". $ SITE_PHP. 'loginnamepassajax. php'. "'";?>, 'Username = '+ document. getElementById ("username "). value + '&' + 'password = '+ document. getElementById ("password "). value, function (msg) {if (! ParseInt (msg) {layer. alert ('user name or Password error! ', {Time: 1000}); return flag;} else {8 9 flag = true; return flag ;}}) ;}); 10 11 return flag;
}