title: Access to XMLHttpRequest at 'file:///sample.txt' from origin 'null' blocked by CORS policy: CORS are only supported for protocol schemes
body: <p>I'm new in AJAX and currently learning very basics of it. In my html file on hitting the submit button I'm just trying to log the text of a text file which is in the same directory of html file itself. But instead I'm getting a error </p>
  
  <p><strong>Access to XMLHttpRequest at 'file:///D:/Front_end_files/AJAX/sample.txt' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.</strong></p>
  
  <p>here's my <code>Ajax-1.html</code></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
      &lt;title&gt;Ajax-1 Text file&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
          &lt;button id="btn"&gt;Click Me&lt;/button&gt;
  
          &lt;script&gt;
              document.getElementById('btn').addEventListener('click',loadtext);
  
              function loadtext(){
  
                  let xhr = new XMLHttpRequest();
                  console.log(xhr);
  
                  xhr.open('GET', 'sample.txt', true);
  
                  xhr.onload = function(){
                      if(this.status == 200){
                          console.log(this.responseText);
                      }
                  };
  
                  xhr.send();
              }
          &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can somebody tell me what am I doing wrong here or is it something new feature with chrome and firefox?</p>