I came across a problem and googling for an answer didn't help.
What I want to do is run an AJAX script that sets a hidden variable on
the form. I call the AJAX script from a javascript function. After the
call, I check the value of that hidden variable and proceed according to
whether it is zero or one.
The problem is that the AJAX call does not complete before the test.
So, I put in a delay after the call to the AJAX function. I even tried
5000 msec. Meanwhile, I looked at the value of the hidden variable
using Firebug. What happens is that the variable does not change until
the delay is completed and the value that the function obtains is the
old value.
It seems as if the AJAX call does not complete until after the delay.
Why would this be so? Shouldn't the AJAX functionality complete while
in the delay?
For the delay, I an using a brute force while loop -- so there is no
setInterval problem here.
So, how can I do this sequence?
1 - Call AJAX which sets the hidden variable.
2 - Delay
3 - Get the changed value