Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/05/2011, 12:15
herrerao
 
Fecha de Ingreso: enero-2009
Mensajes: 8
Antigüedad: 15 años, 3 meses
Puntos: 0
Pregunta Problema: variable fuera de una función ajax

Saludos gente, una ves más acudo a ustedes por que no puedo modificar el valor de una variable que no esta dentro la funcion onreadystatechange de ajax, ya que esta variable la necesito ocupar después para otras validaciones dentro de mi script. el cual es el siguiente:
Código Javascript:
Ver original
  1. function nuevoAjax()
  2. {  
  3.     var xmlhttp=false;  
  4.     try  
  5.     {  
  6.         xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");  
  7.     }
  8.     catch(e)
  9.     {  
  10.         try
  11.         {  
  12.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  
  13.         }  
  14.         catch(E) { xmlhttp=false; }
  15.     }
  16.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }  
  17.  
  18.     return xmlhttp;  
  19. }
  20. var store;
  21. function setstore(dat){
  22.     store = dat
  23.     }
  24. var Ajax=nuevoAjax();
  25.     Ajax.open("POST","test.xml", true);
  26.     Ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  27.     Ajax.send('do=c');  
  28.     Ajax.onreadystatechange=function()
  29.     {
  30.     if (Ajax.readyState==4 && Ajax.status == 200){
  31.         Respuestas=Ajax.responseXML;
  32.         Comprobacion = Respuestas.getElementsByTagName("test")[0].childNodes[0].data;
  33.         setstore(Comprobacion);
  34.  
  35.         }
  36.    
  37.     }
  38. alert(store)
Y cuando alerto a store me muestra undifinied , según yo la variable store es de tipo global.

Espero sus comentarios... Mil gracias de antemano.