Creating a real-time chat with php and javascript Creating a real-time chat with php and javascript php php

Creating a real-time chat with php and javascript


Try use for this CppComet open source comet server. There have api for php and other languages.And viwe this chat example or this


I have already developed an application which is not completely Real-time messaging system, but it works like realtime. Built using without any external new frameworks/API, just used known and familiar skills to develop this using: Ajax jquery, PHP, Mysql, Javascript.

Logic used is:

  1. All messages will be stored in database,
  2. When you load page all messages will be loaded from database.
  3. When you get new messages after reloading, the new messages has to beloaded/displayed without reloading whole page again right? This is done using javaScript and ajax jquery. I have set time out for EVERY 0.5 seconds to reload only new messages and display them.
  4. In my code, At first when the page loads all messages will be loaded in div tags each, Later whenever new message gets into db it will displayed into new
    div tags. its Simple and works without any external API.

To refresh new messages and throw them in to div tags .load() from ajax jquery is used,to refresh every 0.5secs Javascript is used to set timeout.