![]() ![]() JQuery.Deferred() introduces several enhancements to the way callbacks are managed and invoked. For example, in versions prior to jQuery 1.5, asynchronous processes such as jQuery.ajax() accept callbacks to be invoked some time in the near-future upon success, error, and completion of the ajax request. In JavaScript it is common to invoke functions that optionally accept callbacks that are called within that function. Callbacks can still be added to the resolved or rejected Deferred - they will execute immediately. Once the object has entered the resolved or rejected state, it stays in that state. Calling deferred.reject() or deferred.rejectWith() transitions the Deferred into the rejected state and immediately executes any failCallbacks that are set. Calling deferred.resolve() or deferred.resolveWith() transitions the Deferred into the resolved state and immediately executes any doneCallbacks that are set. Any callbacks added to the object with deferred.then(), deferred.always(), deferred.done(), or deferred.fail() are queued to be executed later. The called function can attach callbacks using deferred.then(), for example.Ī Deferred object starts in the pending state. The jQuery.Deferred method can be passed an optional function, which is called just before the method returns and is passed the new deferred object as both the this object and as the first argument to the function. The jQuery.Deferred() factory creates a new deferred object. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |