Organizational Research By

Surprising Reserch Topic

parallel asynchronous ajax requests using jquery


parallel asynchronous ajax requests using jquery  using -'javascript,jquery,ajax'

I'd like to update a page based upon the results of multiple ajax/json requests. Using jQuery, I can "chain" the callbacks, like this very simple stripped down example:

$.getJSON("/values/1", function(data) {
  // data = {value: 1}
  var value_1 = data.value;

  $.getJSON("/values/2", function(data) {
    // data = {value: 42}
    var value_2 = data.value;

    var sum = value_1 + value_2;

    $('#mynode').html(sum);
  });

});


However, this results in the requests being made serially. I'd much rather a way to make the requests in parallel, and perform the page update after all are complete. Is there any way to do this?
    

asked Oct 13, 2015 by virendra.bajaj
0 votes
21 views



Related Hot Questions

8 Answers

0 votes
NULL
answered Oct 13, 2015 by deven.bendale
0 votes
NULL
answered Oct 13, 2015 by badhwar.rohit
0 votes
NULL
answered Oct 13, 2015 by nikhilapatil
0 votes
NULL
answered Oct 13, 2015 by vibhorsingh
0 votes
NULL
answered Oct 13, 2015 by dahiyabecomp
0 votes
NULL
answered Oct 13, 2015 by tejas lakhani
0 votes
NULL
answered Oct 13, 2015 by dhananjayksharma
0 votes
NULL
answered Oct 13, 2015 by deepak07.s

...