To obtain a response from the server, use the responseText or responseXML property of the XMLHttpRequest object.
property | describe |
---|---|
responseText | Get the response data as a string. |
responseXML | Get the response data in XML form. |
If the response from the server is not XML, use the responseText attribute.
The responseText property returns the response as a string, so you can use it like this:
If the response from the server is XML and needs to be parsed as an XML object, use the responseXML attribute:
Request the 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 ;