I’m beginning to work with comet (an ajax-like technology that uses a single connection with multiple server pushes) and found this tutorial extremely helpful:
http://www.zeitoun.net/index.php?2007/06/22/46-how-to-implement-comet-with-php

However, I had to modify the code slightly to work with PHP 4, which doesn’t support json_encode. Instead I just returned the json array manually:

// return a json array
//$response = array();
//$response['msg']       = file_get_contents($filename);
//$response['timestamp'] = $currentmodif;
//echo json_encode($response);
echo "{&92;"msg&92;":&92;"" . file_get_contents($filename) . "&92;",&92;"timestamp&92;":" . $currentmodif . "}";
flush();

I don’t know enough french to navigate or comment on Zeitoun’s site so I thought I’d at least publish this here.

-edit-
Hmm, my code markup plugin seems to be deleting backslashes. I tried replacing them with &92; but they just look like &92;. So replace all &92;s above with \.