Leran JavaScripts

AJAX - Server Response
responseText Property
The responseText property returns the server response as a JavaScript string:
            
  document.getElementById("demo").innerHTML = xhttp.responseText;
            
          
The responseXML Property
The XMLHttpRequest object has an in-built XML parser. The responseXML property returns the server response as an XML DOM object. Using this property you can parse the response as an XML DOM object:
Example
Request the file ajax_info.xml and parse the response:
                
  const xmla = xhttp.responseXML;
  const x = xmla.getElementsByTagName("xml");
  
  let txt = "";
  for (let i = 0; i < xm.length; i++) {
    txt += xm[i].childNodes[0].nodeValue + "
"; } document.getElementById("demo").innerHTML = txt; xhttp.open("GET", "ajax_xml.xml"); xhttp.send();
The getAllResponseHeaders() Method
The getAllResponseHeaders() method returns all header information from the server response.
                
  const xhttp = new XMLHttpRequest();
  xhttp.onload = function() {
      document.getElementById("demo").innerHTML =
      this.getAllResponseHeaders();
  }
  xhttp.open("GET", "ajax_info.txt");
  xhttp.send();