$.ajax To Failure: or not to Failure:

39 Views Asked by At

So I am trying find out if the property "failure" is correct for the following AJAX call. I am finding it all over the place in a new web application I am working on and cannot seem to find it being used in JQuery API docs:

$.ajax({
    type: "POST",
    url: '/AdminTools/HydrateSelectFromDistrict/',
    data: queryStr,
    dataType: 'html',
    beforeSend: OnBegin,
    success: OnDistrictChangeSuccess,
    failure: OnFailure,
    timeout: 5000
});

Shouldn't that property be "error", not "failure"? Never seen the property "failure" used in an AJAX callback

1

There are 1 best solutions below

0
On

I think you're right. It should be "error". I've never seen "failure" either and it isn't in the documentation. I also did not find it in the jQuery code itself.

http://api.jquery.com/jquery.ajax/