Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:53:34+00:00 2026-05-27T10:53:34+00:00

Deferred objects have two main pools of callbacks, namely doneCallbacks and failCallbacks . Both

  • 0

Deferred objects have two main pools of callbacks, namely doneCallbacks and failCallbacks. Both pools are “linear”: the callbacks are stored one after the other in the order they were given in.

This linear structure seems to go against the “tree-like” structure one has to consider when handling errors. At every step, there are two cases: fail and pass.

if(err) {
     // stuff
     if(err) {
          // stuff
     } else {
          // stuff
     }
else {
     // stuff
     if(err) {
          // stuff
     } else {
          // stuff
     }
}

It seems that because of the imposed linearity of Deferreds, they are not very suited for error handling. Am I overlooking something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:53:35+00:00Added an answer on May 27, 2026 at 10:53 am

    It’s a bit wordy but this is from the jQuery documentation for $.when():

    In the case where multiple Deferred objects are passed to jQuery.when,
    the method returns the Promise from a new “master” Deferred object
    that tracks the aggregate state of all the Deferreds it has been
    passed. The method will resolve its master Deferred as soon as all the
    Deferreds resolve, or reject the master Deferred as soon as one of the
    Deferreds is rejected.
    If the master Deferred is resolved, it is
    passed the resolved values of all the Deferreds that were passed to
    jQuery.when. For example, when the Deferreds are jQuery.ajax()
    requests, the arguments will be the jqXHR objects for the requests, in
    the order they were given in the argument list.

    In the multiple-Deferreds case where one of the Deferreds is rejected,
    jQuery.when immediately fires the failCallbacks for its master
    Deferred.
    Note that some of the Deferreds may still be unresolved at
    that point. If you need to perform additional processing for this
    case, such as canceling any unfinished ajax requests, you can keep
    references to the underlying jqXHR objects in a closure and
    inspect/cancel them in the failCallback.

    Source: http://api.jquery.com/jquery.when/

    So if a deferred object resolves to an error then the master deferred fires failCallbacks and it’s up to you to decide what to do with the possibly un-resolved deferreds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A Deferred object has the callback pools doneCallbacks , failCallbacks and progressCallbacks . Both
Code example: http://jsfiddle.net/MhEPw/1/ I have two jQuery Deferred objects. I want to have more
Do jQuery deferred objects have any shorthand to set up dependencies, i.e. "when I'm
I have been researching jquery deferred objects for a while now and I'm stumped
I have a chain of async calls, linked together using dojo.Deferred objects as async
I have actually two questions but they are kind of related so here they
Say you have the following piece of code: function someProcess() { var deferred =
This one i had today is a strange one. I have this query in
I'm starting to use jQuery Deferred objects a bit more and I run into
i have two javascript functions, save() and saveAll() , set up as below: function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.