Ciao a tutti, devo fare una richiesta GET di un file .xml
da un javascript.
Il campo readyState assume valori 1,2 e 4; suppongo
quindi che la richiesta sia andata a buon fine.
Tuttavia non riesco ad accedere al campo status
(che dovrebbe aver valore 200), che non ha nemmeno
valore null, ma semplicemente non è accessibile.
Provo a postare il codice, grazie in anticipo per l'aiuto:
function richiediFileXml()
{
xmlHttp = getXmlHttpObject();
xmlHttp.open("GET","miofile.xml",true);
xmlHttp.onreadystatechange=function()
{
alert(xmlHttp.readyState);
if(xmlHttp.readyState==4)
{
alert(xmlHttp.status);
if(xmlHttp.status==200 || xmlHttp.status==304)
{
xmlCatalogo=xmlHttp.responseXML;
}
}
};
xmlHttp.send(null);
}
function getXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}