I need to be able to control the order of items being processed in the $(document).ready event.
These are multiple controls, loaded from multiple files, all asking to be called in the ready event. They all start an async call to the server (AJAX). Only after they are all done, I need to do some extra work.
What would be the elegant solution for this?
Asynchronous requests fire in order, but will return in whatever order they complete in first. So there is not a sure fire way to force them to end at the same time, however, you can build rules to only run code after certain groups have returned.
For instance, define a callback function with a set of rules, and pass it to each
successcallback for all of your ajax requests.Then set the flags inside of your success functions: