You can use callbacks, here is an example. It basically passes functionB
to functionA
and then calls functionB
at the end of functionA
var functionA = function(cb) {
//do some stuff
cb();
};
var functionB = function() {
//do some stuff
};
functionA(functionB);
Also, if you google javascript callbacks, you'll find many different articles on them. Enough to keep you busy reading for quite awhile.