Today, I met a very painful problem. The asynchronous function $.ajax of jquery is called in one function, and then there is a section of jquery code outside the $.ajax function. Each time the code after the $.ajax is executed first.
Search on the internet for a long time finally found the reason. Take it and share it with everyone before you forget it.
Async:false
var flag=true;
The Async:false representative only executes the
$.ajax ({url: "Emailcheck.ashx", Async:false,data: {"Email": $ ("#email") after waiting for the Ajax execution to complete. Val () }). Done (function (data) {
if (data== "Fail")
{
flag=false;
}
);
if (flag)
{
$ ("#showInfo"). Text ("");
return true;
}
else
{
alert ("This mailbox already exists!");
$ ("#showInfo"). Text ("This mailbox already exists");
return false;
} </span>
Because jquery has not been very proficient, it seems that the future will take time to learn.