Comments for Webdeveloper

Visit Webdeveloper.

  1. Sebastian

    2012-02-01 01:06:47

    Great post, the clearer explanation of promises and deferrers I have read so far.

  2. Viren

    2012-02-01 04:43:10

    How would I can I register a chain of function assigned to done using deferred Something like var promise = wait(); promise.done(result); promise.done(change_result); promise.done(completed); promise.done(done_and_dusted); function result() { $('#result').html('in progress'); } function change_result() { $("#result").html("Waiting to complete ..") } function completed() { $("#result").html("Completed"); } function done_and_dusted() { $("#result").html("Done"); } function wait() { var deferred = $.Deferred(); setTimeout(function() { deferred.resolve(); }, 2000); return deferred.promise(); } With html of "#result" getting chnage in every 2000 millisecond result of function getting executed

  3. Edwin Martin

    2012-02-02 16:44:13

    Viren: to track progress, you can use .notify() and .progress(). See and You can use this since jQuery 1.7.

  4. gerits aurelien

    2012-02-08 15:23:00

    Hello would you have an example with jQuery 1.7 + and ? Best regards :)

  5. jaideep singh

    2012-04-12 08:58:12

    Thanks,learned new Things

  6. Jon-Pierre Gentil

    2012-05-11 18:38:14

    Viren, remember that every time .done is called, a *new* Deferred is returned, so if you're going to assign and then chain, you have to do it as follows: var promise = $.Deferred(); promise = promise.done(something); promise = promise.done(another_thing); promise = promise.done(final_thing); And as Edwin mentioned, use the notify functionality as well.

  7. Gaurav Ramesh

    2012-08-10 14:25:26

    Awesome and nicely written post . Good for starters. Thanks for this .

  8. Midhun Krishna

    2012-08-28 07:58:41

    By far the best explained blog about Deferreds and Promise I have come across. Thanks a lot.

  9. joe

    2012-09-26 15:28:06

    This is a great explanation well done!!

  10. Andy

    2012-12-13 12:30:59

    Thanks, this makes things very clear. The Jquery api docs should include some of these examples as their explanation of it confused the crap out of me!

  11. Rajani

    2013-02-22 10:18:32

    Great Explanation. Thanks..

  12. Michael Zedeler

    2013-03-11 16:31:01

    Your comment regarding propagating failures through jQuery doesn't seem to be valid (the section "Criticism"). Try running this with jQuery 1.8.1: (function() { var jQuery, promise; jQuery = require('jquery'); promise = jQuery.Deferred().reject(); promise.then(function() { return jQuery.Deferred().resolve(); }).then(function() { return console.log('done'); }, function() { return console.log('failed'); }); }).call(this); I get "failed", which indicates that the first then-handler actually does the right thing.

  13. Bibin

    2013-04-01 18:11:40

    Good explanation !!

  14. mohsen

    2013-05-08 06:51:40

    Nice article thanks

  15. David

    2013-05-17 11:01:20

    Thank you. Very nice article. Clear explanations and questions/answers from the point of view of the developper (Why should I use that...)


    2013-06-10 13:13:38

    extremely helpful article

  17. rahul

    2013-07-14 19:42:25

    how to handle in case of multiple url responses to handle in a loop? eg: urls =['/one','two','/three','/four'..] $.each(urls,function(i,url){ $.ajax({ url: url, async: true }); })

  18. Christoph

    2013-09-17 16:13:00

    This is a very nice article, I want to state one thing though: The statement "This time it’s not the events, but the fact that Ajax supports only one callback function. Not only the jQuery $.ajax() call, but also the underlying XMLHttpRequest object." is wrong: It's based on an event subscription model with it's onreadystatechange event, so you could register as many callbacks as you like for one Ajax call. It's just that jquery's old ajax interface wrapped this into an callback paradigm which lacked this possibility. See also this question on Stackoverflow:

  19. Sylvain

    2013-11-05 03:23:40

    Very nice article, thanks alot!

  20. Dmouse

    2013-11-14 20:53:44

    Awesome article! It's quite clear for understanding. Very usefull for me! Thanks a lot!

  21. MIke

    2014-01-02 21:48:12

    Thanks a lot for great article

  22. Mike

    2014-01-08 16:36:05

    Cool! I can understand that.

  23. Terry Jones

    2014-02-03 22:51:21

    Hi Edwin You might be interested in a book on jQuery deferreds that I just co-authored: If you use AUTHD as a discount code on the O'Reilly site, they'll give you 30% or 40% off the price (depending on print or e-book). Terry

  24. Hazar Artuner

    2014-02-14 14:42:41

    This is the best tutorial about this topic, i've looked some of similars but this is very simple and clear, thank you so much :) I've totally understand it :)

  25. Bucki

    2014-03-02 17:34:22

    This is like buying a $10k diamond ring and praising its $100 box. The most important benefit of deferred/promise is that they shift the paradigm of asynchronous programming. Here is a more detailed explanation.

  26. Sanjeev

    2014-09-11 04:24:55

    there are many articles on this topic but all authors are deferring it for new author and this time it is resolved with success status . Thanks

  27. santosh

    2014-12-17 06:20:26

    Excellent article on promise and deffred.

  28. Abhishek

    2014-12-21 14:24:40

    The best explanation of promise and deferred. On a side note, I think the criticism is correct by far.

  29. Blake Frederick

    2015-01-26 06:04:18

    Amazing explanation. Thanks for writing this article!

  30. Anuj

    2015-06-19 04:10:08

    Very helpful article. This is best article I found on deferred and promise. Keep writing.

  31. Varun

    2015-06-22 00:40:50

    Thank you very much! Best explanation..:)

  32. cs

    2015-09-12 13:52:14

    One of the best explanation of promise and deferred.


    2019-08-25 11:17:58

Give your comment:

The sum is to prevent spam. Type your comment below.