I have a little chain of JQuery promises. My problem is at each stage I want to notify my progress to the user, keep them in the loop (Perhaps using .notify somehow?)

What I've eneded up with is this bizarre mess of callbacks and promises. It works but I'm quite certain there is a neater, more logical way to do this.

both fetchSomeData() and Parser() return a promise

    var parseData = function(json)
        showMessage("Updating your data...");
        return new Parser(json);

    var onParseDone = function()

    showMessage("Fetching a bit of data...");
  • 2
    \$\begingroup\$ Am curious, why do you feel the code you posted is a mess? As in, what sort of pseudo code would look pretty? Maybe once I can see where the mess is, I can attempt to clean it up :) If possible, update the question and post a comment stating the same. \$\endgroup\$
    – Amith George
    Aug 22, 2012 at 13:23
  • \$\begingroup\$ I agree with @AmithGeorge, the code above doesnt look that messy to me. \$\endgroup\$
    – sQVe
    Aug 22, 2012 at 13:25
  • \$\begingroup\$ @AmithGeorge it feels like its a bit of strange combination of promises and functions. Don't get me wrong, if general consensus is its good than I'm happy with that! :) \$\endgroup\$
    – JonWells
    Aug 22, 2012 at 13:28
  • 1
    \$\begingroup\$ @ChrimsonChin: You don't need to re-post, moderators can move questions - just flag it for mod attention \$\endgroup\$
    – Bergi
    Aug 22, 2012 at 13:31

1 Answer 1


Surely this is possible. Only the fetch and parse functions would need to call notify with the respective message on the Deferreds they return. The code then could look like this:

fetchSomeData().pipe(parser).progress(showMessage).done(hideMessage, updateView);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.