Q:

unable to load the data to html file from a text file called sample.txt using jQuery

I have a text file called sample.txt and I want to load the data of that file using following HTML file but it would not be loading.   

$( document ).ready(function() {
  jQuery.get('sample.txt', function(theData) {
    alert(theData);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Alert data from text file</h1>
<div><p id="fileData"></p></div>

A:

If you are running locally this can cause errors: 
See this question for more details
Running the HTML code using XAMPP and calling localhost it works without error. 
JQuery.get... is not working using file:/// protocol.

