I suddenly started getting the following:
TypeError: $.ajax(...).done(...).fail(...).complete is not a function
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?
.complete
is deprecated....use .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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With