I am trying to understand the difference between
$.when(...).then(...)
$.when(...).done(...)
in jQuery. As far as I understood both of the
.done()
has only success callback.
.then()
has both success and fail callbacks.
As of jQuery 1.8, the
deferred.then()
method returns a new promise that can filter the status and values of a deferred through a function, replacing the now-deprecateddeferred.pipe()
method.The
deferred.done()
method accepts one or more arguments, all of which can be either a single function or an array of functions.Since
deferred.done()
returns the deferred object, other methods of the deferred object can be chained to this one, including additional.done()
methods. When the Deferred is resolved, doneCallbacks are executed using the arguments provided to the resolve or resolveWith method call in the order they were added.