jQuery deferred.promise()Method
Example
Set two timers with random delay times to resolve and reject the deferred object respectively
Try it »
Definition and Usage
The deferred.promise() function returns the Promise object of a Deferred (delayed) object.
Note:1. This method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal requests.
2. It only contains a set of deferred object methods, including: done(), then(), fail(), isResolved(), isRejected(), always(). These methods can only observe the state of a deferred object, but cannot change the internal state of the deferred object.
3. deferred.promise() can also accept a target parameter. In this case, the passed-in target will be given the Promise methods and returned as the result, instead of creating a new object.
Syntax
| Parameters | Description |
|---|---|
| target | Object type: The object to which the promise methods are bound. |
More Examples
Using the target parameter
Using the target parameter to attach Promise methods to an existing object
Other Extensions
jQuery Miscellaneous Methods