Why aren't my JQuery .ajax requests being made in parallel?

Posted by Ryan Olson on Stack Overflow See other posts from Stack Overflow or by Ryan Olson
Published on 2010-03-29T18:38:45Z Indexed on 2010/03/29 18:43 UTC
Read the original article Hit count: 166

Filed under:
|
|

I am trying to make two ajax requests in parallel using jQuery like this:

    var sources = ["source1", "source2"];

    $(sources).each(function() {
      var source = this;
      $.ajax({
        async: true,
        type: "POST",
        data: {post: "data", in: "here"},
        url: "/my/url/" + source,
        success: function(data) {
          process_result(data);
        }
      });
    });

I got the basic structure from this question, but my requests still aren't being made in parallel. "source1" takes a while to complete, and I can see on the server that the second request isn't made until the first is completed.

As far as I can tell, I don't have any other active requests, so I don't think it's a problem with the maximum number of parallel requests for the browser. Am I missing something else here?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery