Adding requests to the queue: AjaxQueue.push(url, options); // for Ajax.request AjaxQueue.push(url, options, elementId); // for Ajax.updater calls Default batch size is 1.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Irfan, Ghouseuddin Syed Sent: Monday, January 30, 2006 5:57 PM To: [email protected] Subject: RE: [Rails-spinoffs] Multiple ajax calls I have written this small script for queuing ajax calls. Hope this helps. //--------------------------------------------------------------------- var AjaxQueue = { batchSize: 1, urlQueue: [], elementsQueue: [], optionsQueue: [], setBatchSize: function(bSize){ this.batchSize = bSize; }, push: function(url, options, elementID){ this.urlQueue.push(url); this.optionsQueue.push(options); if(elementID!=null){ this.elementsQueue.push(elementID); } else { this.elementsQueue.push("NOTSPECIFIED"); } this.processNext(); }, processNext: function() { if(Ajax.activeRequestCount < AjaxQueue.batchSize) { if(AjaxQueue.elementsQueue.first()=="NOTSPECIFIED") { new Ajax.Request(AjaxQueue.urlQueue.shift(), AjaxQueue.optionsQueue.shift()); var junk = AjaxQueue.elementsQueue.shift(); } else { new Ajax.Updater(AjaxQueue.elementsQueue.shift(), AjaxQueue.urlQueue.shift(), AjaxQueue.optionsQueue.shift()); } } } }; Ajax.Responders.register({ onComplete: AjaxQueue.processNext }); //------------------------------------------------------------------------ All the ajax calls should be pushed into the queue. You can set a batch size ie the no.of simultaneous ajax calls to be processed. Usage: Ex: AjaxQueue.setBatchSize(2); -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Eifion Sent: Monday, January 30, 2006 5:39 PM To: [email protected] Subject: [Rails-spinoffs] Multiple ajax calls This is slightly OT for which I apologise in advance, but I was wondering if anyone here has had any problems when making multiple ajax calls at the same time. I'm working on a large Intranet application which makes heavy use of ajax calls and the bugs are flying in from the testers that if they repeatedly click on a link that makes an ajax call then Internet Explorer can fall over. Obviously I'm making fixes to get around this by disabling the links while the calls are made to stop this but it seems that the way XMLHTTP works in IE and Mozilla is quite different. If a lot of calls are made with IE it seems to try to make them straight away which can cause problems. FireFox on the other hand seems to wait and make the calls sequentially which can take some time, but at least works. I was wondering if anyone else here had noticed anything similar and, if so, if you'd come up with anyway of stopping IE trying to make too many calls at once. Eifion _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
