This might be a good place to use a deferred
Try taking a peek at the [$.when](http://api.jquery.com/jQuery.when/) method which can take an array of deferred objects (jqXHR from $.ajax calls is derived from Deferred) and uses the appropriate callback when all have completed

An empty array also fires immediately simplifying some of this logic