YouTip LogoYouTip

Ajax Xmlhttprequest Response

AJAX XMLHttpRequest Server Response

-- Not just learning technology, but dreams too!

AJAX Tutorial

AJAX Tutorial AJAX Intro AJAX Examples XHR Creating Object XHR Request XHR Response XHR readyState AJAX ASP/PHP AJAX Database AJAX XML AJAX Examples AJAX JSON Examples Fetch API

AJAX – Send to Server

AJAX – onreadystatechange Event

AJAX - Server Response


Server Response

To obtain a response from the server, please use the responseText or responseXML properties of the XMLHttpRequest object.

Property Description
responseText Get response data in string format.
responseXML Get response data in XML format.

responseText Property

If the response from the server is not XML, please use the responseText property.

The responseText property returns the response in string format, so you can use it like this:

Example

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

Try it out Β»


responseXML Property

If the response from the server is XML, and needs to be parsed as an XML object, please use the responseXML property:

Example

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.childNodes.nodeValue + "<br>; }document.getElementById("myDiv").innerHTML=txt;

Try it out Β»

← Ajax Xmlhttprequest OnreadystaAjax Xmlhttprequest Send β†’