Today I encountered a very painful problem. A JQuery asynchronous function $. ajax is called in a function, and a Jquery code is generated after the $. ajax function is added. Every time, code after $. ajax is executed first.
I searched the internet for a long time and finally found the cause. Share it with you so that you do not forget it later.
Async: false
Var flag = true; // async: false indicates that the code is executed only after ajax is executed. ajax ({url: "EmailCheck. ashx ", async: false, data: {" email ": $ (" # email "). val ()}}). done (function (data) {if (data = "Fail") {flag = false ;}}); if (flag) {$ ("# showInfo "). text (""); return true;} else {alert ("this email already exists! "); $ (" # ShowInfo "). text (" this email already exists "); return false ;}</span>
Because I have never been very familiar with Jquery, it seems that I have to spend some time learning it.