Ver Mensaje Individual
  #5 (permalink)  
Antiguo 30/12/2012, 20:35
krosty4782
 
Fecha de Ingreso: enero-2007
Mensajes: 12
Antigüedad: 17 años, 3 meses
Puntos: 0
Respuesta: onLoad =setInterval, seguir mostrando los datos recibidos, no refrescar

A, lo que tengo es en Ajax, lo siguiente:

Código Javascript:
Ver original
  1. <script language="javascript">
  2.         $(document).ready(function() {
  3.            
  4.             $().ajaxStart(function() {
  5.                 $('#loading').show();
  6.                 //$('#result').hide();
  7.             }).ajaxStop(function() {
  8.                 $('#loading').hide();
  9.                 $('#result').fadeIn('slow');
  10.  
  11.             });
  12.             $('#form, #fat, #fo3').submit(function() {
  13.                
  14.                 $.ajax({
  15.                     type: 'POST',
  16.                     url: $(this).attr('action'),
  17.                     data: $(this).serialize(),
  18.                     success: function(data) {
  19.                         $('#result').html(data);
  20.                     }
  21.                 })
  22.                 var comando = document.getElementById("commands").value;
  23.                 comando = comando.replace(" ","");
  24.                 if(comando.substring(0,4)=="exit")
  25.                 {
  26.                     location.href="menuPrincipal.php";
  27.                 }
  28.  
  29.                 document.getElementById("commands").value='';
  30.                
  31.                 return false;
  32.             });
  33.         })  
  34.         </script>

Código Javascript:
Ver original
  1. function objetoAjax(){
  2.     var xmlhttp=false;
  3.     try {
  4.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  5.     } catch (e) {
  6.         try {
  7.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  8.         } catch (E) {
  9.             xmlhttp = false;
  10.         }
  11.     }
  12.  
  13.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  14.         xmlhttp = new XMLHttpRequest();
  15.     }
  16.     return xmlhttp;
  17. }
  18.  
  19. function MostrarConsulta(datos){
  20.     divResultado = document.getElementById('result');
  21.     ajax=objetoAjax();
  22.     ajax.open("GET", datos);
  23.     ajax.onreadystatechange=function() {
  24.         if (ajax.readyState==4) {
  25.             divResultado.innerHTML = divResultado.innerHTML + ajax.responseText;
  26.         }
  27.     }
  28.     ajax.send(null)
  29. }

Última edición por krosty4782; 30/12/2012 a las 23:32