Tutorial by Examples

Here is a very simple example of a function that "promises to proceed when a given time elapses". It does that by creating a new Deferred object, that is resolved later and returning the Deferred's promise: function waitPromise(milliseconds){ // Create a new Deferred object using th...
If you have multiple asynchronous tasks that needs to occur one after the other, you will need to chain together their promise objects. Here is a simple example: function First() { console.log("Calling Function First"); return $.get("/ajax/GetFunction/First"); } fu...
success and Error : A success callback that gets invoked upon successful completion of an Ajax request. A failure callback that gets invoked in case there is any error while making the request. Example: $.ajax({ url: 'URL', type: 'POST', data: yourData, datat...
By default the state of a promise is pending when it is created. The state of a promise is changed when the deferred object which created the promise either resolves/rejects it. var deferred = new $.Deferred(); var d1= deferred.promise({ prop: "value" }); var d2= $("div"...

Page 1 of 1