|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Jan 2006
Messaggi: 81
|
[AJAX] Richiesta GET di un file XML
Ciao a tutti, sto provando a fare una richiesta GET su un file XML,
ma non ottengo nessuna risposta dal server. Ho provato a debuggare il codice ovunque, ed ho notato che dopo aver ottenuto il readyState==4 non succede più nulla. Non riesco nemmeno a verificare se mi venga ritornato un valore di status diverso o uguale a 200. Ringraziandovi in anticipo per la collaborazione, provo a postare il codice nella speranza che possiate aiutarmi: Codice:
var xmlDocument;
var xmlHttp;
function getRichiesta()
{
xmlHttp = getXmlHttpObject();
xmlHttp.open("GET","http://miosito.com/miofile.xml",true);
xmlHttp.onreadystatechange= function()
{
if (xmlHttp.readyState==4)
{
if(xmlHttp.status==200 || xmlHttp.status==304)
{
xmlDocument=xmlHttp.responseXML;
}
}
};
xmlHttp.send(null);
alert(xmlDocument.getElementsByTagName("descrizione")[0].childNodes[0].nodeValue);
}
function getXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:58.



















