0

The jQuery.active variable is set when an ajax call is in process (see jQuery.active function ). I'd like to know if its reset before or after the success (or error) call back functions are done executing. I need to know when the ajax call and all/any callbacks are done, not just when a response came back. Thanks.

Community
  • 1
  • 1
linojon
  • 1,052
  • 1
  • 10
  • 19

1 Answers1

0

Why don't you simply check the value in the ajax callback... then you'll see for yourself if it's changed before or after the callback is finished. I highly doubt it's decremented after the callback, since it's for requests in progress.

If you need to know when the callbacks are done your callbacks and ajax queries will need to modify some state on the page. ie.

  1. ajax request increments variable ajax_processing_in_progress
  2. ajax callbacks decrement variable ajax_processing_in_progress

Edit:

Just realized since JavaScript is "single-threaded" (Is JavaScript guaranteed to be single-threaded?), implementing your own ajax_processing_in_progress that only gets decremented after the callback is finished (ie. at the end of the function block), may be equivalent to decrementing it anywhere in that block for all intents and purposes.

I also recall utilizing jQuery.active variable to in a selenium script so I could wait until the AJAX calls were finished before doing my next user action. In my experience this worked.

Community
  • 1
  • 1
Derek Litz
  • 10,529
  • 7
  • 43
  • 53