jQuery deferred.then()Method
Example
Add .then method
Try it »
Definition and Usage
The deferred.then() function calls the added handlers when the Deferred object is resolved, rejected, or is still in progress.
Note:1. The parameters can be null. Or use .done(), .fail(), or .progress() to set only one type of callback for an unfiltered state or value.
2. Since jQuery 1.8, the method returns a new promise, which can filter the state and value of the deferred object through a function, replacing the now deprecated deferred.pipe() method.
3. The callbacks are executed in the order they were added. Since deferred.then returns a Promise object, it can be chained with other Promise objects, including additional .then() methods.
Syntax
Method 1
Method 2
| Parameters | Description |
|---|---|
| doneFilter | Function type Optional. A function that is called when the Deferred object is resolved. |
| failFilter | Function type Optional. A function that is called when the Deferred object is rejected. |
| progressFilter | Function type Optional. A function that is called when the Deferred object generates progress notifications. |
| Parameters | Description |
|---|---|
| doneCallbacks | Function type. A function or an array of functions called when the Deferred object is resolved. |
| failCallbacks | Function type. A function or an array of functions called when the Deferred object is rejected. |
| progressCallbacks | Function type. A function or an array of functions called when the Deferred object generates progress notifications. |
More Examples
Filter resolved values
Filter resolved values.
Filter rejected values
Filter rejected values.
Chain tasks
Chain tasks.
Other Extensions
jQuery Miscellaneous Methods