From b5272bc8d658bf74fa226b73071a8398b4c01c53 Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Mon, 20 Jul 2015 01:06:12 +0100 Subject: [PATCH] deferred.always: Added note for parameters changing order Fixes #763 --- entries/deferred.always.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/entries/deferred.always.xml b/entries/deferred.always.xml index 57b3cf7f..30e92193 100644 --- a/entries/deferred.always.xml +++ b/entries/deferred.always.xml @@ -17,6 +17,7 @@ Add handlers to be called when the Deferred object is either resolved or rejected.

The argument can be either a single function or an array of functions. When the Deferred is resolved or rejected, the alwaysCallbacks are called. Since deferred.always() returns the Deferred object, other methods of the Deferred object can be chained to this one, including additional .always() methods. When the Deferred is resolved or rejected, callbacks are executed in the order they were added, using the arguments provided to the resolve, reject, resolveWith or rejectWith method calls. For more information, see the documentation for Deferred object.

+

Note: The deferred.always() method receives the arguments that were used to .resolve() or .reject() the Deferred object, which are often very different. For this reason, it's best to use it only for actions that do not require inspecting the arguments. In all other cases, use explicit .done() or .fail() handlers since the arguments will have well-known orders.

Since the jQuery.get() method returns a jqXHR object, which is derived from a Deferred object, we can attach a callback for both success and error using the deferred.always() method.