Any way to stop the code execution and then resume it? For example, next code will not run until a flag value is changed and then resume it.
Edit: I have a code that starts a loop of AJAX requests and I need to control (with a flag if its possible) thats loop when the user visits other tabs of the browser to stop it. Then, when the user returns to the application, loop would resume.
The problem would be solved with setInterval
to AJAX requests and a flag to stop them. But I think that is more correct to do the loop of AJAX requests from the success ajax function, i.e. when the response is done, because I am using a MVC pattern and have the ajax function in a model and the called is done from de view. And then, the loop with setInterval
would start in a wrong side
however, I am thinking that "setInterval" could be in the AJAX called function