gpt4 book ai didi

javascript - XHR 不再适用于 jQuery $.ajax

转载 作者:太空宇宙 更新时间:2023-11-04 15:30:32 24 4
gpt4 key购买 nike

我有以下内容:

$.ajax(options)
.then(function (response) {
// success
}, function (response, a, b) {
// fail
})
.always(function (output, status, xhr) {
// xhr is always null here
});

以前,xhr 可用。如何使用最新版本的 jQuery 访问它?

最佳答案

您可以使用 jquery 3.2 实现如下所示。新版本的 jquery 已弃用以前的一些 ajax 方法。

var jqxhr = $.ajax( "yourUrl" )
.done(function() {
console.log("success");
})
.fail(function() {
console.log("error");
})
.always(function(xhr, status,output ) {
console.log(xhr);
});

关于javascript - XHR 不再适用于 jQuery $.ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44827268/

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