Could maybe look at using jquery deferred objects to chain the callbacks in sequence