How do I make a function wait until all jQuery Ajax requests are done inside another function?
In short, I need to wait for all Ajax requests to be done before I execute the next. But how?
How do I make a function wait until all jQuery Ajax requests are done inside another function?
In short, I need to wait for all Ajax requests to be done before I execute the next. But how?
I have met this problem and created a generic plugin jquery_counter to solve it: https://bitbucket.org/stxnext/jquery_counter/
jQuery allows you to specify if you want the ajax request to be asynchronous or not. You can simply make the ajax requests synchronous and then the rest of the code won't execute until they return.
For example:
$.when
doesn't work for me,callback(x)
instead ofreturn x
worked as described here: https://stackoverflow.com/a/13455253/10357604