Firing a callback when all ajax requests in a chain of ajax calls are done. Code courtesy: http://goo.gl/gnpmE

JQuery WhenAll()
jsfiddle.net