title: callback execution order in jQuery getJSON
body: <p>I'm trying to implement a iGoogle like dashboard interface using widgets that get their content from other sites using JSONP calls.</p>
  
  <p>The problem is that if the first widget that calls the "$.ajax" takes 8 seconds to get the content back, it seems that the callbacks of the other widgets will only be called after the callback of the first widget gets executed. For the user experience, it would be better if the widgets could be displayed as soon as they get the content back from the remote sites, and not wait for those that were scheduled before to complete.</p>
  
  <p>Is there a way I can do that?</p>
  
  <p>EDIT :
  I use jquery 1.4.1.</p>
  
  <p>I tested on Chrome and the behaviour seems to be different than on Firefox.</p>
  
  <p>Here is a script that I've made up to try to get what happens :</p>
  
  <pre><code>  function showTime(add) { console.log(getTime() + ': ' + add); }
    function getNow() { return new Date().getTime(); }
    initialTime = getNow();
    function getTime() { return getNow() - initialTime; }
    function display(data) {  showTime('received a response'); }
  
    showTime("Launched a request");
    jQuery.getJSON("http://localhost:51223/WaitXSeconds/3?callback=?", display);
    showTime("Launched a request");
    jQuery.getJSON("http://localhost:51223/WaitXSeconds/4?callback=?", display);
    showTime("Launched a request");
    jQuery.getJSON("http://localhost:63372/WaitXSeconds/9?callback=?", display);
    showTime("Launched a request");
    jQuery.getJSON("http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&amp;type=javascript&amp;callback=?", display);
    showTime("Launched a request");
    jQuery.getJSON("http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&amp;country=US&amp;callback=?", display);
  </code></pre>
  
  <p>The first three calls are just fake calls that wait the specified number of seconds.
  Note that I use two different servers implementing this method.</p>
  
  <p>Here is the result in the console on Firefox 3.6.2 :</p>
  
  <pre><code>0: Launched a request
  3: Launched a request
  6: Launched a request
  11: Launched a request
  14: Launched a request
  3027: received a response
  7096: received a response
  9034: received a response
  9037: received a response
  9039: received a response
  </code></pre>
  
  <p>.. and here is the result in Chrome 4.1.249.1036 (41514) :</p>
  
  <pre><code>1: Launched a request
  2: Launched a request
  3: Launched a request
  4: Launched a request
  5: Launched a request
  165: received a response
  642: received a response
  3145: received a response
  7587: received a response
  9157: received a response
  </code></pre>
  
  <p>It seems that in Firefox, the two requests to the two public APIs get called at the end, after all the other calls succeed.</p>
  
  <p>Chrome, on the other hand, manages to execute the callback as soon as it receives the response.</p>
  
  <p>On both browsers, when the request happen on the same server, they are not done in parallel. They are scheduled one after the other. But I guess this is a reasonable behaviour.</p>
  
  <p>Can anybody explain Firefox's behaviour or has any hack to go around this?</p>