如何获取Jquery.ajax成功函数的返回值 [英] How to get the return value of the Jquery.ajax succes function

查看:631
本文介绍了如何获取Jquery.ajax成功函数的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些这样的代码

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?

推荐答案

您不能.异步JavaScript和XML是异步.

You can't. Asynchronous JavaScript and XML is Asynchronous.

当HTTP请求返回时,回调函数将运行,届时doSomething将完成执行.

The callback function will run when the HTTP request comes back, by which time doSomething will have finished executing.

无论您希望响应HTTP响应而发生什么,都必须在回调函数中完成,而不是在任何称为回调的函数中完成.

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.

这篇关于如何获取Jquery.ajax成功函数的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆