C.Joseph Drayton wrote:
Hi Marten,
When I use 'false' as the third parameter in makeRequest, I never a
response.
I understand what you say about making the GUI wait, but for my
purposes, it is imperative that no other processing occur until that
response is received and processed.
So is there a way to make JavaScript wait until that response is
received?
I am doing this kind of thing frequently (getting info from the server
and waiting on the client till the info comes back), but I use a
completely different architecture, which is simple enough.
In the main document, put an <IFRAME src="" name=ifComm id=ifComm>.
Then, the script that requests the info should as its last line set the
src of the IFRAME to the appropriate thing (it is also possible to
POST, by specifying the target=ifComm), for example by
document.getElementById('ifComm').src='myPhpPage.p hp'. It is up to the
returned page to kick of the next step of the process by having an
onload script that does something like top.mySubsequentFunction()
Thus, waiting is accomplished not by looping (which may be blocking
other things from happening) until you see a certain value change, but
by code finishing until you have an event (the onload of the returned
document) kick off the next step in the process.
Csaba Gabor from Vienna
Example returned page:
<html><head><title>PHP server response</title></head>
<body onload=loaded()>
<script type='text/javascript'>
function loaded() { top.HoneyImBack(); }
</script>
Dummy text to see that server responded
</body></html>
where in the main page you might have
function HoneyImBack() { alert('waiting is over'); }