JSFiddle - React, Tailwind, and code Playground

by Doug Hill

JavaScript

function process(){
        
        var async1 = $.when( a1() ).then(function(){ return a2(); });
        var async2 = $.when( a3() ).then(function(){ return a4(); });

        $.when(async1, async2).then(function(){ 
                console.log("compelete");
                
                
            });        
    }
    
    function a1(){
        var dfd = $.Deferred();
        
        setTimeout(function(){ console.log("a1 done"); dfd.resolve();  },3000);
         
        return dfd.promise();         
    }
    
    function a2(){
        var dfd = $.Deferred();
        
        setTimeout(function(){ console.log("a2 done"); dfd.resolve();  }, 4000);
         
        return dfd.promise();         
    }

    function a3(){
        var dfd = $.Deferred();
        
        setTimeout(function(){ console.log("a3 done"); dfd.resolve();  }, 5000);
         
        return dfd.promise();         
    }
    
    function a4(){
        var dfd = $.Deferred();
        
        setTimeout(function(){ console.log("a4 done"); dfd.resolve();  }, 6000);
         
        return dfd.promise();         
    }    
    
    process()