0

Please can any body help me with a simple script on how to write an ajax longing in php.

I doing some on chat and have been using the old polling. so I want to switch to long pooling. so the browser would only display messages when there is a new message in the database

Thanks for taking out time to read my post.

4
Contributors
3
Replies
19
Views
4 Years
Discussion Span
Last Post by pritaeas
0

An old project called APE (comet) has been kicking around for a while. You need to set up your own server for this as I don't think Apache can do it. The solutions I've seen for php tend to be 'repeated polling' as opposed to long polling - not really comet in other words (e.g. http://www.zeitoun.net/articles/comet_and_php/start) - which may overwhelm the server. Using some flavour of timeout for sleep() periods should force the end of the poll though, otherwise you could have major processing even though the user has gone away.

0

Sidenote, assuming you build this from scratch: suppose you implement long polling for an AJAX call to PHP. This would just move the problem to the PHP script, as it would need to implement the same original polling mechanism to get info from the database.

Perhaps moving to Javascript for this would be the better solution, using node.js (if possible).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.