title: Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest'
body: <p>I need to display hello world using servlet program in browser by Ajax call but on clicking button I am not to display it what could be reason of this error:</p>
  
  <blockquote>
    <p>Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///D:/workspace/Poc_Ajax/WebContent/WEB-INF/HelloWorld'.</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function getXMLHttpRequest() {
      var xmlHttpReq = false;
      // to create XMLHttpRequest object in non-Microsoft browsers
      if (window.XMLHttpRequest) {
          xmlHttpReq = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
          try {
              // to create XMLHttpRequest object in later versions
              // of Internet Explorer
              xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (exp1) {
              try {
                  // to create XMLHttpRequest object in older versions
                  // of Internet Explorer
                  xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (exp2) {
                  xmlHttpReq = false;
              }
          }
      }
      return xmlHttpReq;
  }
  /*
   * AJAX call starts with this function
   */
  function makeRequest() {
      var xmlHttpRequest = getXMLHttpRequest();
      xmlHttpRequest.onreadystatechange = getReadyStateHandler(xmlHttpRequest);
      xmlHttpRequest.open("POST", "HelloWorld", true);
      xmlHttpRequest.setRequestHeader("Content-Type",
              "application/x-www-form-urlencoded");
      xmlHttpRequest.send();
  }
  
  /*
   * Returns a function that waits for the state change in XMLHttpRequest
   */
  function getReadyStateHandler(xmlHttpRequest) {
  
      // an anonymous function returned
      // it listens to the XMLHttpRequest instance
      return function() {
          if (xmlHttpRequest.readyState == 4) {
              if (xmlHttpRequest.status == 200) {
                  document.getElementById("hello").innerHTML = xmlHttpRequest.responseText;
              } else {
                  alert("HTTP error " + xmlHttpRequest.status + ": " + xmlHttpRequest.statusText);
              }
          }
      };
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;Getting Started with AJAX using JAVA: Hello World!&lt;/div&gt;
  &lt;div id="hello"&gt;&lt;button type="button" onclick="makeRequest()"&gt;Say Hello!&lt;/button&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>