AJAX XMLHttpRequest server response
Server Response
To get a response from the server, use or responseXML responseText property of the XMLHttpRequest object.
Attributes | description |
---|---|
responseText | Get a string of response data. |
responseXML | Get XML form of the response data. |
responseText property
If the response from the server is not XML, use the responseText property.
responseText property returns a string response, so you can use:
responseXML property
If the response from the server is XML, but also as an XML parsing object, use responseXML properties:
Examples
Request cd_catalog.xml file and parse the response:
xmlDoc=xmlhttp.responseXML;
txt="";
x=xmlDoc.getElementsByTagName("ARTIST");
for (i=0;i<x.length;i++)
{
txt=txt + x[i].childNodes[0].nodeValue + "<br>";
}
document.getElementById("myDiv").innerHTML=txt;
txt="";
x=xmlDoc.getElementsByTagName("ARTIST");
for (i=0;i<x.length;i++)
{
txt=txt + x[i].childNodes[0].nodeValue + "<br>";
}
document.getElementById("myDiv").innerHTML=txt;
try it"