Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery deferred.rejectWith() method

jQuery deferred.rejectWith() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods


Definition and Usage

The deferred.rejectWith() function is used to reject a deferred object and call any failCallbacks with the given context and args.

**Note:** 1. Typically only the creator of the deferred object can call this method. You can call deferred.promise() to return a restricted Promise object, preventing other code from changing the state of the deferred object or reporting its state.
2. When the deferred object is rejected, any failCallbacks added via deferred.then or deferred.fail are called. The callbacks are executed in the order in which they were added. The args passed to deferred.reject() are passed to each callback. After the deferred object enters the rejected state, any failCallbacks added afterwards are executed immediately with the arguments passed to .reject().


Syntax

deferred.rejectWith( context [, args ] )

Parameters Description
context Object type: Passed as the this object to the failCallbacks
args Array type: An optional array of arguments passed to the failCallbacks

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods