gpt4 book ai didi

jquery - $.ajaxSetup 是否控制 $.getJSON

转载 作者:行者123 更新时间:2023-12-01 08:02:39 24 4
gpt4 key购买 nike

我正在尝试关闭应用程序中的所有 AJAX,请参阅 here .

使用ajaxSetup控制getJSON吗?

即此 getJSON 请求是同步的吗?

// TURNING OFF ALL AJAX
$.ajaxSetup({
async: false
});

$.getJSON(window.url_root + '/app/settings/1/', function(data) {
window.authenticated = data['is_user_authenticated'];
});

最佳答案

是的!来自 jQuery 网站关于 $.ajaxSetup()

All subsequent Ajax calls using any function will use the new settings, unless overridden by the individual calls, until the next invocation of $.ajaxSetup().

Note: The settings specified here will affect all calls to $.ajax or AJAX-based derivatives such as $.get(). This can cause undesirable behavior since other callers (for example, plugins) may be expecting the normal default settings. For that reason we strongly recommend against using this API. Instead, set the options explicitly in the call or define a simple plugin to do so.

这就像所有 ajax 请求的全局设置。

关于jquery - $.ajaxSetup 是否控制 $.getJSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18835130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com