I have functions that do AJAX requests, how can I make these functions execute in order they are called in JavaScript?
function1(); // some
function2(); // AJAX
function3(); // happens
function4(); // in
function5(); // each function
I want function2 to wait until function1 is complete and function3 to wait until function2 is complete and so on...
Javascript is Asynchronous so you need to have a callback on each function that does something when that function is finished.
More info : http://recurial.com/programming/understanding-callback-functions-in-javascript/
Here is some info on how to add callbacks to your functions :