tags:

views:

1889

answers:

4

I have an app that sends multiple Ajax requests simultaneously. I was originally running into race conditions until I discovered the jQuery Ajax Queue plugin, which works great with jQuery 1.2, but fails with jQuery 1.3. There are actually two different versions of the plugin; I am currently using this one which is the same as the first but just adds a bit more functionality.

Anyway, I am using Firebug on Firefox 3.0.10 and when I run my code I don't receive any explicit errors, the call is just never returned.

I could obviously continue using v1.2 but would really like to learn why this plugin fails with the latest release and what I can do to get it working.

Thanks in advance.

+7  A: 

You should be able to use jQuery's built-in queue support if you're willing to do a bit of legwork.

// First Ajax request
$(document).queue("ajaxRequests", function() {
  $.ajax({
    // Stuff
    success: function() {
      $(document).dequeue("myName");
    });
  });
});

// Second Ajax request
$(document).queue("ajaxRequests", function() {
  $.ajax({
    // Stuff
    success: function() {
      $(document).dequeue("myName");
    });
  });
});

// Trigger the queue
$(document).dequeue("ajaxRequests");

Of course, it would be pretty easy to wrap that in a plugin.

Yehuda Katz
A: 

ajaxManager plugin is based on the Ajax Queue Plugin but is a bit more flexible and works with jQuery 1.3.2.

Sam Hasler
A: 

Hi;

is there a way to show a spinner image before a request and than display a message ( ie "complete" ) when a request is completed ?

tks

A: 

Just found the answer to this looking for a solution myself. Someone decided to modify the original ajaxQueue plugin.

http://www.onemoretake.com/2009/10/11/ajaxqueue-and-jquery-1-3/

Ryan