是否有可能设置异步:假以.getJSON $电话 [英] Is it possible to set async:false to $.getJSON call

查看:134
本文介绍了是否有可能设置异步:假以.getJSON $电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能设置异步:假打电话时 $的getJSON()因此调用块,而。不是被异步?

Is it possible to set async: false when calling $.getJSON() so that the call blocks rather than being asynchronous?

推荐答案

您需要使用 $阿贾克斯() 它同步,就像这样:

You need to make the call using $.ajax() to it synchronously, like this:

$.ajax({
  url: myUrl,
  dataType: 'json',
  async: false,
  data: myData,
  success: function(data) {
    //stuff
    //...
  }
});

这将使用 $匹配当前。的getJSON() 是这样的:

This would match currently using $.getJSON() like this:

$.getJSON(myUrl, myData, function(data) { 
  //stuff
  //...
});

这篇关于是否有可能设置异步:假以.getJSON $电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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