Ok i am tryin to make a Chatting application where users can chat with each other if theyr logged in to the website. I have set up everything except a little working which i am not able to write.
In my example : 2 users are chatting with each other : User A and User B
When User A submits a comment in the Chat Window , then the whole div containing the Comments should be refreshed not only at User A’s side but also at User B’s side so that when User A submits the comment, User B should be able to see it.
In short refreshing the div on every users page when a new record is added to the database table.
Im good in PHP, Jquery, AJAX.
If you’re comfortable restricting your users to new technologies, your best bet is to look into HTML5
websocketAPI. It’s still a bit green around the gills, but it’s certainly the way these things will be done in the near future. Kaazing’s default example is a chat client, actually.On the server side, there are implementations for websockets in JavaScript (Node.js), Java, and other technologies, but I’m not sure about PHP.
If you don’t want to use websockets, research techniques that fall under the name “COMET” or search for “long polling”. These will be far more responsive than a time interval.
If on the other hand you don’t need it to be super-responsive, you could just use
setIntervalto have both clients poll the server for changes.