Ver Mensaje Individual
  #18 (permalink)  
Antiguo 21/01/2014, 17:19
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Problema con estado 1 en loader

Ya lo he resuelto, lo comparto para los que como yo están empezando en este maravilloso mundo. A ver como lo veis, si se puede mejorar por favor decirmelo:

Código Javascript:
Ver original
  1. function valida_envia(e)
  2. {
  3.   if (window.event)
  4.     window.event.returnValue=false;
  5.   else
  6.     if (e)
  7.       e.preventDefault();
  8.   enviarFormulario();
  9. }
  10.  
  11. var conexion1;
  12. function enviarFormulario()
  13. {
  14.   conexion1=crearXMLHttpRequest()
  15.   conexion1.onreadystatechange = procesarEventos;
  16.   var telefonos = document.forms['datos'].elements['telefonos'];
  17.   alert('Valor de la propiedad readyState:'+conexion1.readyState);
  18.   conexion1.open("GET", "val_telef.php?telefonos=" + telefonos.value, false);
  19.   conexion1.send(null);  
  20. }
  21.  
  22.         function procesarEventos()
  23.         {
  24.         alert('Valor de la propiedad readyState:'+conexion1.readyState);
  25.         var resultados = document.getElementById("carga1");
  26.         if(conexion1.readyState == 4)
  27.         {
  28.         resultados.innerHTML = conexion1.responseText;
  29.        
  30.    
  31.        
  32.          var xml = conexion1.responseXML;
  33.             dato=xml.getElementsByTagName("datos");
  34.             if(dato[0].firstChild.nodeValue=="1")
  35.             {
  36.                 num_user=xml.getElementsByTagName("numusuario");
  37.                
  38.                
  39.                 document.getElementById("movil").value =xml.getElementsByTagName("movil")[0].firstChild.nodeValue;
  40.                 document.getElementById("calle").value =xml.getElementsByTagName("calle")[0].firstChild.nodeValue;
  41.                 document.getElementById("dni").value =xml.getElementsByTagName("dni")[0].firstChild.nodeValue;
  42.                 document.getElementById("name").value =xml.getElementsByTagName("name")[0].firstChild.nodeValue;
  43.                 document.getElementById("edificio").value =xml.getElementsByTagName("edificio")[0].firstChild.nodeValue;
  44.                 document.getElementById("numero").value =xml.getElementsByTagName("numero")[0].firstChild.nodeValue;
  45.                 document.getElementById("puerta").value =xml.getElementsByTagName("puerta")[0].firstChild.nodeValue;
  46.                 document.getElementById("piso").value =xml.getElementsByTagName("piso")[0].firstChild.nodeValue;
  47.                 document.getElementById("letra").value =xml.getElementsByTagName("letra")[0].firstChild.nodeValue;
  48.                 document.getElementById("localidad").value =xml.getElementsByTagName("localidad")[0].firstChild.nodeValue;
  49.                 document.getElementById("provincia").value =xml.getElementsByTagName("provincia")[0].firstChild.nodeValue;
  50.                 document.getElementById("email").value =xml.getElementsByTagName("email")[0].firstChild.nodeValue;
  51.                
  52.            
  53.                  
  54.        
  55.             }
  56.    
  57.         }
  58.         else
  59.         if (conexion1.readyState==1 || conexion1.readyState==2 || conexion1.readyState==3)
  60.         {
  61.         resultados.innerHTML = "<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...";
  62.            }
  63.         }
  64.      
  65.  
  66.     function crearXMLHttpRequest()
  67. {
  68.   var xmlHttp=null;
  69.   if (window.ActiveXObject)
  70.     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  71.   else
  72.     if (window.XMLHttpRequest)
  73.       xmlHttp = new XMLHttpRequest();
  74.   return xmlHttp;
  75. }


Gracias