I want to make a seres of function calls in order in javascript. My case is that I want to upload a few images to the server one by one but I don't know how to do that in javascript. Below is a method to solve a sync call for a know number of functions.
    $('#art1').animate({'width':'1000px'},1000,'linear',function(){
        $('#art2').animate({'width':'1000px'},1000,'linear',function(){
            $('#art3').animate({'width':'1000px'},1000);        
        });        
    });        
You can see that there are three functions chained together. It works if I know the number of functions in the first place. But how to achieve this for unknown the number of functions?
 
     
     
    