I’m calling a javascript function provided by a third-party. This function fires off a few ajax/asynchronous requests before returning, and (impolitely) neither allows me to pass a callback, nor returns any references to the asynchronous calls it is making.
Is there any way I can trigger something when all of the calls it’s making complete?
Is there a way I can track ‘calls’ launched from a javascript function? Forgive my terminology; I’m a javascript beginner.
Is this a library that’s loaded from an external source, or do you have your own local copy? In the latter case, you could patch the code to do what you want. Otherwise, I don’t really see a way to directly intercept the calls.
If you know exactly what state changes occur for each completed async call, you could set a function to execute on an interval (setInterval(fn, millis)) and check whether all those states have been met. Then, you could fire off some sort of final function to indicate completion.
ie: