I have a search form with default values.
As the user loades the page, onload I call a function.
This function has a loop, which calls a Ajax Request with each iteration.
I take about 20 to 30 Seconds will all the Ajax Request are executed.
During these Iteration user can change form values and can Submit the form
before these iterations are completed.
Is there a way to break that loop as the user clicks on the submit button?
Thanks.
Sort of, before each ajax request is called, have it check for a flag. Say for example it could be intiialised on page load as
CARRY_ON = true;Now when the submit button is pressed, change the flag to false. Then all future ajax requested will be stopped.