Deprecation of success Parameter in jQuery.ajax?

There is a difference between, the Ajax success callback method:

$.ajax({}).success(function(){...});

and the Ajax success local callback event (i.e., the Ajax parameter and property):

$.ajax({
    success: function(){...}
});

The success callback method (first example) is being deprecated. However, the success local event (second example) is not.

Local events are Ajax properties (i.e., parameters). The jQuery docs further explain that the local event is a callback that you can subscribe to within the Ajax request object.

So in future, you may do either:

$.ajax({}).done(function(){...});

or

$.ajax({
    success: function(){...}
});

Leave a Comment