javascript function wait until another function to finish
In my opinion, deferreds/promises (as you have mentionned) is the way to go, rather than using timeouts. Here is an example I have just written to demonstrate how you could do it using deferreds/promises. Take some time to play around with deferreds. Once you really understand them, it becomes very easy to perform asynchronous tasks. Hope this … Read more