JQuery

Delayed object-deferred.then(doneFilter [, failFilter ] [, progressFilter ])

Delayed object-deferred.then(doneFilter [, failFilter ] [, progressFilter ]), someone asked me to explain?

Overview

When the add handler is called, the deferred object is resolved or rejected.

All three parameters (including progressCallbacks, 1.7 in jQuery) can be a single function or an array of functions. One of the parameters can also be empty, if no callback of that type is needed. Alternatively, use only .done() or .fail() to set only doneCallbacks or failCallbacks. When deferred is resolved, doneCallbacks is called. If deferred instead of rejecting, failCallbacks is called. Callbacks are executed in the order they were added. Once deferred.then returns a lingering object, other methods of deferring the object can also be linked here, including adding the .then() method. See the file Deferred object for details .

parameter

doneFilter [, failFilter ] [, progressFilter ] String V1.8

doneFilter : A function that is called when a Deferred object is resolved.

failFilter : [Optional] A function that is called when a Deferred object is rejected.

progressFilter : [optional] A function that is called when a Deferred object generates a progress notification.

doneCallbacks, failCallbacks String V1.5

doneCallbacks : An array of functions or functions that are called when the delay is successful.

failCallbacks : An array of functions or functions that are called when the delay fails.

doneCallbacks, failCallbacks [, progressCallbacks] String V1.7

doneCallbacks : An array of functions or functions that are called when the delay is resolved.

failCallbacks : An array of functions or functions that are called when the delay is denied.

progressCallbacks: An optional function that is called when the delay object notifies the progress.

Example

description:

Once the jQuery.get method returns a jqXHR object from the deferred object, we can attach a successful callback using the .then method.

jQuery code:
 $.get("test.php").then(
        function () { alert("$.get succeeded"); },
        function () { alert("$.get failed!"); }
    );


 

Post your comments / questions