gpt4 book ai didi

javascript - TypeError : $. ajax(...).done(...).fail(...).complete 不是函数

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:40:55 24 4
gpt4 key购买 nike

我突然开始得到以下信息:

TypeError: $.ajax(...).done(...).fail(...).complete is not a function

我的代码:

this.sendRequest = function (type, extension, data, successCallback, successMsg, failMsg, failCallback) {

var self = this;
var options = {
url: self.baseUrl + self.apiEndpoint + extension,
type: type,
dataType: 'json',
xhrFields: {
withCredentials: true
}
};
if (data != null) {
options.data = data;
}
return $.ajax(options)
.done(function (response) {
// do stuff
})
.fail(function (response) {
// do stuff
}).complete(function (response) {
// do stuff
});
};

为什么会这样?我确实更新了 jQuery - 某些语法是否失效?

最佳答案

.complete 已弃用....使用 .always

jqXHR.always(function( data|jqXHR, textStatus, jqXHR|errorThrown ) { }); (added in jQuery 1.6)

An alternative construct to the complete callback option, the .always() method replaces the deprecated .complete() method.

关于javascript - TypeError : $. ajax(...).done(...).fail(...).complete 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43403812/

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