Chat with php and ajax

Hello, please help with adding online entries. Made a chat: the user adds a message, it is written to the letters.dat file. Further records are output. In the same chat, it would be more convenient to use online addition. Refresh every 5 seconds is not the best way, maybe ajax will help? How can this be organized?


Answer 1, authority 100%

Do you really think Uncle Ajax is something that will save you from having to update something every 5 seconds? You will be disappointed, but – this is just a technology that allows you to make asynchronous requests to the server, people say easier, without reloading the page. You have to follow the rules and standards. As I understand it, you created a chat, through a frame, with a refresh of 5 seconds, and so, ajax – it will be the same, only without a frame. I assume you are interested in something like a persistent connection to the server, via Commet.

dklab_multiplexor: persistent Javascript connection to the server in the face of hundreds of thousands of online clients