I am trying to load a text file that is stored on my local machine to a div when a button is clicked
My HTML
<!DOCTYPE html>
<html>
<head>
<title>Help</title>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<button id="magic">Click me</button>
<div class="here"></div>
</body>
</html>
My JavaScript
$(document).ready(function() {
$("#magic").click(function(){
$(".here").load("helloworld.txt");
});
});
My text file
helloworld.txt which says hello world!!!!
The error I am getting in the inspector is :
jquery-3.1.1.min.js:4 XMLHttpRequest cannot load file:///home/justin/Code/test/helloworld.txt. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.