managing multiple jQuery promises
The new jQuery 1.5 version has support for promises. Promises allows code to be dependent on the completion of an asynchronous event. Promises are most commonly used when making an AJAX request. I recently had to solve a problem where I was issuing many AJAX requests and wanted to make sure all were completed before moving on to the next task. To make matters more complicated, I was issuing the requests using jsonp. Some of the requests were chained from other requests as well. Trying to track all the promises by individually was becoming a mess. After speaking with a colleague, I set about creating a function to manage multiple promises.