Forum Moderators: open

Message Too Old, No Replies

question about XMLHttpRequest();

         

icpooreman

1:43 am on Nov 27, 2005 (gmt 0)

10+ Year Member



I just started learning about how XMLHttpRequest() works today and got it to request xml from my server in sort of a trial run. I was wondering if I could add the functionality of a chat with this to my webpage.

This leads to several questions my first and most importantly being does the client have to request the information being sent to it with this object. Ideally for the least messages being sent from server to client and processing on the server you'd want the server to send out the text to all logged in every time it receives a new text string from any client.

So is it possible with this object to wait for a message from the server rather than request it (again I'm new to this and all the examples I've found have been requesting info from the server)? Because if it's not then this idea is just about dead because in order to get the true feel of being in a chat you'd have to constantly request information from the server which is not what I want.

JAB Creations

2:46 am on Nov 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes and effectively at that!

The basic concept can be seen if you look up "XHTML chat XMLHttpRequest Object"

A very advanced and very cool chat (that suckfully is forprofit) can be found looking up "Chat - Treehouse City Guide".

If you find an open source version of the more advanced chat please by ALL means make me aware of it!

icpooreman

5:14 am on Nov 27, 2005 (gmt 0)

10+ Year Member



Thanks for pointing me in the right direction. However unfortunately I now am convinced that a request has to originate from the client. All of the example chats I found (every single one and I found like 10) used a setTimeout or setInterval function and constantly checked with the server as to if any new messages had been sent. I guess that's why they didn't name it XMLHttpResponse().