 <p>Maybe you could use <a href="https://api.jquery.com/promise/" rel="nofollow"><code>.promise()</code></a> for this. </p> <p>You can add a promise to the upload function. This way you could run functions like <code>upload.done(function(e) { /* do stuff */ });</code> </p> <p>The <a href="https://api.jquery.com/jQuery.ajax/" rel="nofollow"><code>$.ajax()</code></a> in jQuery has its build-in promise. You can check if an ajax call succeeded with <code>xhr.done(function(e) { /* do stuff */ });</code></p>