I use jQuery.Deferred and register done , fail and then handlers:
$.when( some_ajax(url) ) .done(function(result){}) .fail(function(){}) .then(function(){}); //just like that, with a single parameter
I found that when my ajax call succeeds, the done and then callbacks are called in that order. However, when ajax fails, the fail callback is called, but I do not get the then callback.
I read the jQuery.Deferred documentation but did not find any clue as to the reason for this behavior.
When using always instead of then it is called in both cases - success and failure (first done / fail is called, then always is called). The documentation does not indicate the expected difference between always and then in my described scenario, why do they behave differently?
jquery jquery-deferred
Hai
source share