AJAX SERVER RESPONSE

The web service response can be collected in text format (responseText) or XML (responseXML).

AJAX responseText

To collect the answer in text format:

xmlhttp.responseText;

Example of using the retrieved text

document.getElementById("myDiv").innerHTML=xmlhttp.responseText;

AJAX responseXML

To collect the response in XML format

xmlhttp.responseXML;

Example use of XML recovered

xmlData=xmlhttp.responseXML; text=""; x=xmlData.getElementsByTagName("firstName"); for (i=0;i<x.length;i++) { text=text + x[i].childNodes[0].nodeValue + "<br>"; } document.getElementById("myDiv").innerHTML=text;