This simple piece of code is not working, what should I do now
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ajax Tutorials</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$('#btn').click(function(){
$('#test').load("data.txt", {
Name: "Vijesh",
Lastname: "Arora",
}, function(){
alert("Hi idiot!");
});
});
});
</script>
</head>
<body>
<div id="test"><p>This is the first content!</p></div>
<button id="btn">Click to change</button>
</body>
</html>
I have created the data.txt file in the same directory where this index.html is placed.
ERROR
XMLHttpRequest cannot load file:///Applications/XAMPP/xamppfiles/htdocs/php/ajax/data.txt. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.