Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/08/2014, 13:38
KikeLo
 
Fecha de Ingreso: julio-2013
Mensajes: 4
Antigüedad: 10 años, 10 meses
Puntos: 0
Respuesta: PHP y innerHTML en javascript

Muchas gracias Alexis88

Código HTML:
 var seconds = 4; // intervalo de actualizar div

  
  //aca nomas va el codigo
  var datos = [
        {divid: 1, url: "cuadros/1.php"}, 
        {divid: 2, url: "cuadros/2.php"}
    ],
    total = datos.length;
  //aca no mas

   for (var i = 0; i < total; i++){
    objetoajax1(datos[i].divid, datos[i].url);
     function objetoajax1(divid, url){
  
         // The XMLHttpRequest object
  
         var xmlHttp;
         try{
             xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
         }
         catch (e){
             try{
                 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
             }
             catch (e){
                 try{
                     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                 }
                 catch (e){
                     alert("Tu explorador no soporta AJAX.");
                     return false;
                 }
             }
         }
  
         // Timestamp for preventing IE caching the GET request
         var timestamp = parseInt(new Date().getTime().toString().substring(0, 10));
         var procesourl = url+"?t="+timestamp;
  
         // The code...
  
         xmlHttp.onreadystatechange=function(){
             if(xmlHttp.readyState== 4 && xmlHttp.readyState != null){
                 document.getElementById(divid).innerHTML=xmlHttp.responseText;
				// document.getElementById(divid2).innerHTML= url2;
                 setTimeout('objetoajax1()',seconds*1000);
             }
         }
         xmlHttp.open("GET",procesourl,true);
         xmlHttp.send(null);
     }
	   if(i == 3){
	  var i = 0;
  }
   }
     window.onload = function(){
         objetoajax1(); // Ejecutamos objetoajax
      }
Me carga los dos pero ya no actualiza continuamente los divs!!! =(