[jQuery] Re: How can I make sure one AJAX call returns before another?

2008-09-22 Thread Mickster

Maybe this is something for you:
http://welcome.totheinter.net/2008/09/21/bundled-and-ordered-asynchronous-ajax/
Haven't read it myseld yet, but judging from the subject of the
article, it might help you.

I found it on the jQuery-tweet here: http://twitter.com/jquery

Regards,
Mickster

On Sep 22, 7:51 pm, Namlet [EMAIL PROTECTED] wrote:
 I have several AJAX calls.  Most of them retrieve values for drop-down
 lists and one fills in the data.  Of course, unless the drop down
 lists are fully loaded, the data filler doesn't select them properly.
 Is there anyway to trigger the data filler after they are complete
 with more sophistication than setTimeout?

 BTW, I've tried ajaxStop but that causes an infinite loop since the
 data filler triggers it again.

 Thanks!


[jQuery] Re: How can I make sure one AJAX call returns before another?

2008-09-22 Thread Eric

Well, here's a bit of a hackish solution, but you basically want to
keep track of what happens when the first batch of Ajax calls
complete.  You do this by specifying functions to be called when the
Ajax calls finish (succeed). http://docs.jquery.com/Ajax/jQuery.ajax#options

Let's say you have three functions in the first wave and then you
want to call your data filler:

var counter;

function start_first_wave() {
   counter = 0; // set counter back to zero.
   // trigger ajax calls for first three, specifying 'completed_func'
as the success function for the ajax call
}

function completed_func() {
  counter = counter + 1;
  if ( counter == 3 ) {  start_data_filler() }
}

Of course, you'd probably want to name space these, provide for the
case where an AJAX call fails, etc.



On Sep 22, 1:51 pm, Namlet [EMAIL PROTECTED] wrote:
 I have several AJAX calls.  Most of them retrieve values for drop-down
 lists and one fills in the data.  Of course, unless the drop down
 lists are fully loaded, the data filler doesn't select them properly.
 Is there anyway to trigger the data filler after they are complete
 with more sophistication than setTimeout?

 BTW, I've tried ajaxStop but that causes an infinite loop since the
 data filler triggers it again.

 Thanks!