function getreturnajax{
$.ajax ({
Type: "Post",
http://www.111cn.net/userexist.asp Tutorial X ",
Data: "Username=" +vusername.value,
Success:function (msg) {
if (msg== "OK") {
Showtipex (Vusername.id, "<b><font color= ' #ffff00 ') > The username can be used </font ></b> ", false)
return true;
}
Else
{
Showtipex (Vusername.id, "<b><font color= ' #ffff00 ') > The user has been registered </ Font></b> ", false);
Vusername.classname= "Bigwrong";
return false;
}
}
});
}
But we call this getreturnajax () always get false, that is to say return True,return false does not work at all, in Firefox under the Firebug debugging also proved that the code will not be executed to the return section.
What if we just try to define a variable in a function, then assign it in Ajax, and finally return the variable at the end of the function? We modified the code as follows:
Code
Copy code code as follows:
function Getajaxreturn ()
{
var Bol=false;
$.ajax ({
Type: "Post",
http://www.111cn.net/userexist.asp Tutorial X ",
Data: "Username=" +vusername.value,
Success:function (msg) {
if (msg== "OK") {
Showtipex (Vusername.id, "<b><font color= ' #ffff00 ') > The username can be used </font ></b> ", false)
return true;
Bol=true;
}
Else
{
Showtipex (Vusername.id, "<b><font color= ' #ffff00 ') > The user has been registered </ Font></b> ", false);
Vusername.classname= "Bigwrong";
return false;
}
}
});
return BOL;
}