Is there any way, in javascript, to call on a other function when the first function is “ready”
something like this:
ridiculousTimeConsumingFunction().onReady( newFunction() );
To illustrate my example you can take a look her:
http://web.cinaird.se/pdf/test.htm
ridiculousTimeConsumingFunction();
newFunction();
Will execute
newFunction()afterridiculousTimeConsumingFunction()has finished.You could also do something like
ridiculousTimeConsumingFunction(newFunction);, and have ridiculousTimeConsumingFunction defined as follows:Which would have the same effect.
Infact, scrap all that, because it’s an asynchronous event, not a time consuming function… You’ll have to use a callback:
Then call it as follows: