Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2011, 07:50
Avatar de 0kool
0kool
 
Fecha de Ingreso: julio-2006
Ubicación: En el país de la libertad
Mensajes: 35
Antigüedad: 17 años, 9 meses
Puntos: 0
Pregunta Esto da error en Firefox y IE lo ejecuta bien

Hola, estoy intentando hacer una consulta al AJAX de Google, el código me funciona bien para IE pero en firefox no =(... dejo el código y abajo los errores que genera:


Código:
// XML url
var url= 'http://maps.google.com/maps/api/elevation/xml?locations=40.728397037445035,-73.99609565734863&sensor=false&Elevation_Units=METERS';

// XML url
// var url= 'http://maps.google.com/maps/api/elevation/json?locations=40.728397037445035,-73.99609565734863&sensor=false&Elevation_Units=METERS';



function processChange() { 
    // 4 means the response has been returned and ready to be processed 
    if (obj.readyState == 4) { 
        if (obj.status == 200 ) { 
      var xml_data = obj.responseText; 
      alert("XML DATA: "+xml_data); 
               // process whatever has been sent back here: 
               // anything else means a problem 
        } else { 
            alert("There was a problem in the returned data:\n"); 
        } 
    } 
} 
 
var obj; 
 
function ProcessXML(url) { 
  // native  object 
 
  if (window.XMLHttpRequest) { 
    // obtain new object 
    obj = new XMLHttpRequest(); 
    // set the callback function 
    obj.onreadystatechange = processChange; 
    // we will do a GET with the url; "true" for asynch 
    //  
    obj.open("GET", url, true); 
    // null for GET with native object 
    obj.send(null); 
  // IE/Windows ActiveX object 
  } else if (window.ActiveXObject) { 
    obj = new ActiveXObject("Microsoft.XMLHTTP"); 
    if (obj) { 
      obj.onreadystatechange = processChange; 
      obj.open("GET", url, true); 
      // don't send null for ActiveX 
      obj.send(); 
    } 
  } else { 
    alert("Your browser does not support AJAX"); 
  } 
} 
// LLamo a la funcion 
ProcessXML(url);
Errores en Firefox 3.6.13 (Todo esto en IE 8 no pasa, sale todo ok)
1- Cuando quiero verificar: obj.status == 200 FF siempre responde el "alert";
2- Si quito "obj.status == 200" ésto--> "alert("XML DATA: "+xml_data);" sale vacío o null.

Espero me puedan ayudar hace 2 días que busco como solucionarlo, antes intente con JSON en lugar de XML pero me pasa exactamente lo mismo!!!.