score:0

You need to make deferred jquery function calls something like this:

function test(){
          var defer = $.Deferred();
          setTimeout(function(){console.log("prints 1st");defer.resolve();},1000);
          return defer;
 }
function test2(){
       console.log("prints 2nd");
      return $.when();
 }
test().then(test2).then(function () {
           console.log("prints at the end.");    
 });

Here is a working example http://jsbin.com/payitucami/edit?html,console


Related Query

More Query from same tag