开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜