Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I go about getting the Ajax Queue plugin working in jQuery 1.3?

Tags:

jquery

ajax

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.

like image 658
J.C. Yamokoski Avatar asked May 19 '09 06:05

J.C. Yamokoski


2 Answers

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.

like image 170
Yehuda Katz Avatar answered Oct 31 '22 19:10

Yehuda Katz


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/

like image 45
Ryan Avatar answered Oct 31 '22 19:10

Ryan