How To Run Sequence Functions In Javascript
How to run sequence functions in JavaScript: I've 4 functions like this: function myfunction() { callfunction1(); callfunction2(); } In callfunction1: function callfunction1
Solution 1:
JavaScript is single-threaded, callfunction2
will only run after callfunction3
has compeletely finished.
However, if callfunction3
contains some AJAX or other asynchronous operation, then that will always happen after callfunction2
(because of the single-threaded thing, it can't start the asynchronous callback until after the synchronous stuff is done). Anything that relies on the result of an asynchronous function MUST either be in the function itself, or called by said function.
Post a Comment for "How To Run Sequence Functions In Javascript"