Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/01/2010, 07:01
TragedyCL
 
Fecha de Ingreso: enero-2010
Mensajes: 39
Antigüedad: 14 años, 3 meses
Puntos: 1
Respuesta: Actualizar un div

Ah dale, utilizare el mismo script anterior

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. var tmp="";
  3.  
  4. setInterval(function actualiza()
  5. {
  6.     ajax=nuevoAjax();
  7.     ajax.open("GET", "ajax_select_db.php?var1="+var1+"var2="+var2); // En ajax_select_db debes hacer el SELECT al query
  8.  
  9.     ajax.onreadystatechange=function()
  10.     {
  11.         if (ajax.readyState==4)
  12.         {
  13.             // Si el valor devuelto por AJAX no es el mismo que tenemos en TMP entonces lo muestra, si no, almacena el contenido en TMP para una siguiente revision cada X tiempo (X lo define el Setinterval... no disminuyas mucho el tiempo para no saturar la BD.
  14.             if(!(ajax.responseText==$tmp)
  15.             {
  16.                  document.getElementById("contenedor_datos").innerHTML = ajax.responseText;
  17.             } else {
  18.                  $tmp=ajax.responseText;
  19.         }
  20.     }
  21.     ajax.send(null)
  22. ,10000);
  23. </script>

Suerte