开发者

How to get the return value of the Jquery.ajax succes function

开发者 https://www.devze.com 2023-02-02 06:51 出处:网络
I 开发者_如何学Gohave some code like this function doSomething(){ Jquery.ajax(type: \"POST\", url: \"HelloWorld\",

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

精彩评论

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