I found this in a thread here called 'jquery doing comet'. It didn't
work for me unmodified. I also modified it a
little and it still doesn't work. Can someone tell me what's wrong?

Bob



here is the html file:
-------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
   <title>Collecting Data...</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/
>
   <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
</head>
<body>

<div id="comet_frame" style="display:none;visibility:hidden"></div>
<div id="content"></div>

<script type="text/javascript">
   var comet = {
      load: function() {
         $("#comet_frame").html('<iframe id="comet_iframe"
src="backend.php"></iframe>');
      },

      unload: function() {
         $("#comet_frame").html('<iframe id="comet_iframe" src=""></
iframe>');
      },

      clearFrame: function() {
         $("#comet_iframe").html("");
      },

      time: function(ctime) {
         $("#content").html(ctime);
      }
   }

   $(document).ready(function() {
      comet.load();
   });

</script>


<body>
</body>
</html>


here is backend.php:
----------------------

<?php
   set_time_limit(0);
   header("Cache-Control: no-cache, must-revalidate");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   flushHard();

   $x = 0;

   while(1) {
      if($x == 10) {
         echo '<script type="text/javascript">parent.comet.clearFrame
();</ script>' . "\n";
      }
      else {
         echo '<script type="text/javascript">parent.comet.time("' .
date('H:i:s') . '");</script>' . "\n";
      }
      flushHard();
      ++$x;
      sleep(1);
   }
   echo '<script type="text/javascript">parent.comet.unload();</
script>' . "\n";
?>


Reply via email to