I am looking for a way to stop a function's normal execution temporarily. The scenario is something like this:
I have a function that needs to return something to its caller and this can't be changed. This function used to call another function before starting its execution and needs to wait until the other function completes. Once the other function completes this function can start its execution.
As you know this will return undefined from foo2. What I want to do is the return statement should be executed only after the complete execution of foo1 function.
k = 1000;
In my case I am dealing with Ajax calls but the issue here is the location of the return statement, which I can't change.
I will not be able to use the setTimeout/setInterval...