Hi Folks, I need to fire off the same ajax request for many elements on a page, if I were to do something like: (given divs[] array is filled with the elements I wish to process) for ( i=0;i<divs.length;i++) { new Ajax.Request(''/your/url'', { onSuccess: fillit(divs[i],transport) other parameters here: } } function fillit(destination,transport) { destination.innerHTML=transport.responseText } Would the requests all be queued up nicely and execute in turn or would they overlap so that only the last one really gets processed properly? many Thanks, Robin. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-May-24 23:47 UTC
Re: behavior of multiple ajax requests in prototype
They''ll all get processed properly. They''ll wait in line and be executed asynchronously on however many channels the user''s browser is configured to send at a time (usually 2). -Fred On Sat, May 24, 2008 at 3:54 PM, Zedsquared <robinb-bVQUo+yCxtbcsi6rw0m61Q@public.gmane.org> wrote:> > Hi Folks, > I need to fire off the same ajax request for many elements on > a page, if I were to do something like: > > > Would the requests all be queued up nicely and execute in turn or > would they overlap so that only the last one really gets processed > properly? > > many Thanks, > Robin. >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I would probably send all stuff in a single request. Maybe build up a single string with that loop and send it like "your/url/? div[0]=a&div[1]=b" etc. Just my two cents, but I think it would reduce the traffic too. Whatever, I''ve been doing ajax only some months now. Ta. On May 24, 11:54 pm, Zedsquared <rob...-bVQUo+yCxtbcsi6rw0m61Q@public.gmane.org> wrote:> Hi Folks, > I need to fire off the same ajax request for many elements on > a page, if I were to do something like: > > (given divs[] array is filled with the elements I wish to process) > > for ( i=0;i<divs.length;i++) { > new Ajax.Request(''/your/url'', { > onSuccess: fillit(divs[i],transport) > other parameters here: > } > > } > > function fillit(destination,transport) { > destination.innerHTML=transport.responseText > > } > > Would the requests all be queued up nicely and execute in turn or > would they overlap so that only the last one really gets processed > properly? > > many Thanks, > Robin.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---