If you *really* need to make sure they execute in order, you''ll have to
implement some sort of queueing of your own. Shouldn''t be hard.
I''d do
something like this:
1) Create a global object to manage your queue. QManager lets say. Give it
an array, called queue, and a function called "add"
2) Add a global handler for the Ajax.responders onComplete event.
3) Instead of firing requests directly, call your QManager "add"
function.
The function should enqueue the request and check if any requests are
processing right then. If so, you''re done, because the onComplete event
will
pick it up. If not, kick off the first element in the queue.
4) In the onComplete event of your registered Ajax.responders, check if
there are any queued items, and process them if they exist.
Never actually tried this myself, but it should work...not to hard.
Good luck!
-Jerod
On 7 Mar 2006 18:49:37 -0000, Dave Teare <
devlists-scriptaculous-mifkN9UeCURWk0Htik3J/w@public.gmane.org>
wrote:>
> To answer your first question, the the body''s ONLOAD command is
executed
> once the page has completed loading. Having script in your HTML gets
> executed at different times depending on the browser (at least
that''s my
> experience).
>
> As for the other questions, why do you need 2-3 ajax calls to execute on
> page load? You should be able to do everything you need in once
> request. For example, check out the code for PalmSphere.com; it uses an
> XHR to load JavaScript code from the server, and then eval''s it -
this
> is used to populate some JS array''s, etc. Then, I use use JS to
> interpret the data and act accordingly (i.e. mark favorites, update
> favorite counter, etc.). In fact in DevLists I abandoned this method
> entirely and simply populated the JS arrays during the intial page
> render; it caused the back button to break sometimes, but the improved
> performance was worth it.
>
> HTH.
>
> On Tuesday, March 07, 2006, at 7:37 PM, Jan Deppisch wrote:
> >Hi,
> >
> >currently I execute 2-3 AJAX-Calls (located at the end of html-body) on
> >loading the page. I run into problems now because they are executed
> >parallel of course :)
> >
> >How can I garuantee that the Calls are executed when the page has
loaded
> >completely ?
> >
> >And, more interesing, how can I make one AJAX-Call start when the
> >previous has completely finished ?
> >
> >I''ve read about Effect.Queues - is that the keyword ??
> >
> >Thanks for your help
> >Jan
> >
> >_______________________________________________
> >Rails-spinoffs mailing list
> >Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
> Cheers!
> --Dave Teare
> http://devlists.com - Email list management
> http://palmsphere.com - Apps for your hand-held
>
>
> --
> Posted with http://DevLists.com. Sign up and save your time!
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs