[英]TypeError: $.ajax(…).done(…).fail(…).complete is not a function
I suddenly started getting the following: 我突然开始得到以下内容:
TypeError: $.ajax(...).done(...).fail(...).complete is not a function TypeError:$ .ajax(...)。done(...)。fail(...)。完成不是一个函数
My code: 我的代码:
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
});
};
Why is this happening? 为什么会这样? I did update jQuery - did some of this syntax become invalidated? 我确实更新了jQuery - 这个语法有些失效吗?
.complete
is deprecated....use .always
.complete
已被弃用....使用.always
jqXHR.always(function( data|jqXHR, textStatus, jqXHR|errorThrown ) { }); jqXHR.always(function(data | jqXHR,textStatus,jqXHR | errorThrown){}); (added in jQuery 1.6) (在jQuery 1.6中添加)
An alternative construct to the complete callback option, the .always() method replaces the deprecated .complete() method . 完整回调选项的替代构造,.always()方法替换了不推荐使用的.complete()方法 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.