|
Posted by one man army on 01/24/06 10:09
In article <6af7.43d4b96a.110f8@clunker.homenet>,
Jasen Betts <jasen@free.net.nz> wrote:
>
> > , the result of the query was not there yet. Apparently
> > there is some kind of event loop or somesuch that queued the execution
> > of the PHP. The result was there visibly in the browser window, and on
> > inspection with the Firefox DOM inspector.
>
> I'n not sure what you mean by event loop, yes the result it not there
> immediately but will arrive soon (depending on network etc...)
>
> AIUI the object has an onload property that can be used to activate code
> after it has loaded (and executed) basically this is like any other event
> handler....
>
> This means you can't reliably do a synchronous request, your script must run
> in two parts, one to request the result and a further part to handle the
> result.
>
> there's a different handler if it fails but I forget the name
>
> > This is my first Javascript program so I am more than willing to
> > change the design approach as appropriate. I appreciate thoughful
> > comments or suggestions, and do appreciate the answers I have read on
> > USENET that let me get as far as I have.
>
> basically you need to saw it in half and have one half making requests and
> the other half handling the responses.
>
I also just found the Javascript setTimeOut() call, though in this
book its listed as not being part of DOM. Better than a Mutation event
handler?
In other words, After setting off a PHP/JS snippet using
document.body.appendChild(), the last line sets up a one off function
call using setTimeOut() to look for the response, which is set into the
document somewhere in a pre-arranged element, for example a hidden INPUT.
Navigation:
[Reply to this message]
|