Net-informations.com
SiteMap  | About    

What are deferred and promise object in jQuery?



A deferred object is an object than can create a promise and change its state to resolved or rejected. It is used to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

A promise is, as the name says, a promise about a future value. Together with the Promise object , Deferred represents the jQuery implementation of promises. You can attach callbacks to it to get that value. It possesses a subset of the methods of the Deferred object : always(), done(), fail(), state(), and then().

deferred.promise()

You cannot use $.Promise(); because it does not exist. The deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request.









net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.