Ver Mensaje Individual
  #5 (permalink)  
Antiguo 13/10/2012, 07:13
edie8
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 12 años, 5 meses
Puntos: 10
Respuesta: dudas con este codigo

e buscao y e encontrao un ejemplo pero solo me imprime numeros en nada que meto una cadena de texto ya no me imprime nada que tengo mal lo tengo asi:
index.html
Código HTML:
Ver original
  1.     <title>Comet demo</title>
  2.     <style type="text/css">
  3.         .hiddenIframe {
  4.             position:absolute;
  5.             top:0px;
  6.             left:0px;
  7.             display:block;
  8.             z-index:-999;
  9.             visibility:hidden;
  10.         }
  11.     </style>
  12. </head>
  13. <div id="content"></div>
  14. <script type="text/javascript">
  15.  
  16.     var content = document.getElementById('content');
  17.     var dumpText = function(text){
  18.         content.innerHTML = content.innerHTML + '<BR>'+ text;
  19.     }
  20. <iframe src="backEnd.php" class="hiddenIframe"></iframe>
  21. </body>
  22. </html>
otro.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. /*
  4. Simple COMET script tested to work with IE6, IE8, IE9, Chrome 5, Chrome 10, Firefox 3.6.16, Firefox 4, Safari 5, Opera 11
  5. */
  6.  
  7. header("Cache-Control: no-cache, must-revalidate");
  8. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  9.  
  10. //Turn of Apache output compression
  11. // Necessary if you have gzip setup in your httpd.conf (e.g. LoadModule deflate_module modules/mod_deflate.so)
  12. apache_setenv('no-gzip', 1);
  13. ini_set('zlib.output_compression', 0);
  14.  
  15. //Disable all PHP output buffering
  16. ini_set('output_buffering', 'Off');
  17. ini_set('implicit_flush', 1);
  18.  
  19. for ($i = 0, $level = ob_get_level(); $i < $level; $i++) { ob_end_flush(); } //Flush all levels of the buffer to start
  20.  
  21.  
  22. ?><html>
  23. <head>
  24.   <title>Comet php backend</title>
  25. </head>
  26. <body>
  27. <script type="text/javascript">
  28.     var dumpText = window.parent.dumpText;
  29. </script>
  30. <?php
  31.  
  32. $startTime = time();
  33. $maxLoopTime = 10;
  34. include('config.php');
  35. $comentarios=mysql_query("select * from comentarios",$conexion);
  36. while($comen=mysql_fetch_array($comentarios)) {
  37.  $come=$comen['id'];
  38.     echo '<script type="text/javascript">';
  39.     echo "dumpText(".$come.');'.str_repeat(' ',500); //500 characters of padding
  40.     echo "</script>\r\n";
  41.  
  42.     flush();
  43.  
  44.     $randSleep = mt_rand(100000, 2000000); //sleep between 100 ms and 2 seconds
  45.     usleep($randSleep);
  46. }
  47.  
  48. ?>
  49. <script type="text/javascript">dumpText("Output Finished");</script>
  50. </body>
  51. </html>

lo he modificado y si los id me los imprime pero si quiero sacar los comentarios ya no me imprime nada. un saludo.