I have a JS function that makes an AJAX call several times, based on how many checkboxes are checked on the page. On each iteration, I check the value of a hidden field with document.getElementById().value; if it's false, the function is supposed to break.
The value of the hidden field is set by clicking a button elsewhere on the page, it's initially set to true.
My problem is: if I call that function, and change the value of the hidden field to "false" with the button while the function is looping, the function still sees the hidden field as "true". The function does not see the new value during its execution. If I call the function a second time after this, it sees the appropriate field value as "false"
I made a second button that brings up an alert() with the value of the hidden field, and this is always correct.
I've tried using a global variable instead of a hidden field, the same problem occurs. The same thing happens in both IE and Firefox.
Why doesn't the function see the updated value of the hidden field? Any help would be appreciated, thanks!