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 9310191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:03:12+00:00 2026-06-19T01:03:12+00:00

I have following code: var aReq = $.getJSON(‘/path/A’), bReq = $.getJSON(‘/path/B’); $.when(aReq, bReq).then(function(A, B)

  • 0

I have following code:

var aReq = $.getJSON('/path/A'),
    bReq = $.getJSON('/path/B');

$.when(aReq, bReq).then(function(A, B) {
  console.log(A, B);
  // logs: [Array[5], "success", Object], [Array[20], "success", Object]
});

Why is this wrapped in a “jqXHR array”?

With a single $.getJSON this doesn’t happen:

var aReq = $.getJSON('/path/A');
$.when(aReq).then(function(A) {
  console.log(A);
  // logs: [Object, Object, Object, Object, Object]
  // just like I wanted it in the first version
});

Is there a way to accomplish that the first version works? Maybe I understood something wrong with promises/deferred objects.

FWIW: I am using jQuery version 1.7.1 in this case.

  • 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-06-19T01:03:13+00:00Added an answer on June 19, 2026 at 1:03 am

    This is well documented in the api as the intended behavior: http://api.jquery.com/jQuery.when/

    If it wasn’t returned in an array, how would it return different results for each passed in promise considering each passed in promise could have multiple arguments returned?

    From the documentation:

    If a single argument is passed to jQuery.when and it is not a Deferred
    or a Promise, it will be treated as a resolved Deferred and any
    doneCallbacks attached will be executed immediately. The doneCallbacks
    are passed the original argument. In this case any failCallbacks you
    might set are never called since the Deferred is never rejected.

    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.

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

Sidebar

Related Questions

I have following code snippet: var reg = /^[0-9]$/; $('input[type=text]').keypress(function(){ console.log(reg.test(parseInt($(this).val()))); }); When I
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
I have the following code: var submitHandler = function ($link, $form, close) { var
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where
I have the following code: var from = 0, step = 5; function showNext(list)
I have the following code: var string = word1;word2;word3,word4,word5,word6.word7; function ends_with(string, character) { var
I have the following code: var words = new Object(); $(li.words).each(function(){ var thisId =
I have the following code: var XmlDoc = new XmlDocument(); Console.WriteLine(); Console.WriteLine(response.ReadToEnd()); Console.WriteLine(); //
I have the following code: var formSubmitHandler = function (link, form) { //e.preventDefault(); var
I have the following code: var parentEls = $(root) .find(credit standard) .parents() .map(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.