Hi,
I am working on a simple chat program and want to use AJAX. In order to
get the new lines added to the chat I need to call a server-side script,
say every x seconds.
A second way to get those lines is to get them as a reply to the "add this
line" request when someone pressed the send button (or just enter).
So my idea was to:
get lines, and add them to the chat
setTimeOut for 5 seconds to get lines
if someone presses send, remove the setTimeOut, and
after receiving lines, setTimeOut for 5 seconds
The main question is: are the onClick handler and the setTimeOut atomic?
What I mean, should I see a browser as handling events atomic, and both
are events, hence it's not possible that the function registered with
setTimeOut is called in the "middle" of the onClick handler?
Thanks,
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
I am working on a simple chat program and want to use AJAX. In order to
get the new lines added to the chat I need to call a server-side script,
say every x seconds.
A second way to get those lines is to get them as a reply to the "add this
line" request when someone pressed the send button (or just enter).
So my idea was to:
get lines, and add them to the chat
setTimeOut for 5 seconds to get lines
if someone presses send, remove the setTimeOut, and
after receiving lines, setTimeOut for 5 seconds
The main question is: are the onClick handler and the setTimeOut atomic?
What I mean, should I see a browser as handling events atomic, and both
are events, hence it's not possible that the function registered with
setTimeOut is called in the "middle" of the onClick handler?
Thanks,
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
Comment