jQuery deferred.rejectWith()Method
Definition and Usage
The deferred.rejectWith() function is used to reject a Deferred object and call any failCallbacks callback functions based on the given context and args parameters.
Note:1. Usually only the creator of the Deferred object can call this method. You can prevent other code from changing the state of the Deferred object or reporting its status by calling deferred.promise() to return a restricted Promise object.
2. When the Deferred object is rejected, any failCallbacks added via deferred.then or deferred.fail will be called. The callbacks are executed in the order in which they were added. The args parameter passed to deferred.reject() is passed to each callback function. After the Deferred object enters the rejected state, any failCallbacks added later are executed immediately with the arguments passed to .reject().
Syntax
| Parameters | Description |
|---|---|
| context | Object type: Passed to the fail callback functions (failCallbacks) as the this object. |
| args | Array type: Pass an optional array of arguments to the fail callback functions (failCallbacks). |
Other Extensions
jQuery Miscellaneous Methods