jq ajax fail,javascript - jQuery.ajax fail handler not called - Stack Overflow

Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

But when I use the following code:

$.ajax({

type: 'GET',

url: '@Url.Page("Create", "History")',

contentType: 'application/json',

dataType: 'json',

data: { 'name': value },

done: function (response) {

alert('done' + response);

},

fail: function (response) {

alert('fail' + response);

},

error: function (response) {

alert('error' + response);

},

success: function (response) {

alert('success' + response);

},

});

If my Razor Pages handler throws an exception, the error response is shown. (And nothing is shown if I delete the error handler.)

I don't mind using fail if it's preferred. But if it's not going to be called on errors it won't do much good.

UPDATE: I can also see that the done handler also doesn't get called unless I change it to success.

UPDATE: It looks like I'm using jQuery 3.3.1.