jQuery: What is the difference between deferred.always() and deferred.then()?

Niyaz picture Niyaz · Sep 16, 2012 · Viewed 10.9k times · Source

Seems to me that both does the same thing.

Docs:

Answer

JamesHalsall picture JamesHalsall · Sep 16, 2012

It would seem that deferred.then() allows you to pass two separate callbacks for success and failure, whereas deferred.always() takes n number of callbacks which will all be called regardless of the outcome of the initial event.

I would say use deferred.always() in the cases where success/failure of the initial event are not important