How to get the return value of the Jquery.ajax succes function
I 开发者_如何学Gohave some code like this
function doSomething(){
Jquery.ajax(type: "POST",
url: "HelloWorld",
success: function (msg) {
if(msg.d =="Hello World")
{
return true;
}else
{
return false;
}
}
);
}
i want to know something based on which the return value of the succes function. Can somebody help?
You can't. Asynchronous JavaScript and XML is Asynchronous.
The callback function will run when the HTTP request comes back, by which time doSomething
will have finished executing.
Whatever you want to happen in response to the HTTP response returning has to be done in the callback function and not in whatever called it.
精彩评论