I am new to javascript promises and I want to load the content of a file into a specific element but I get a 403 Forbidden error. Any idea how to get access to the LOCAL file that I am trying to load?
function openFile (page) {
$('#load').load(page);
}
function getFile (callback) {
let req = new XMLHttpRequest();
req.open('GET', "/includes/addons/load.html");
req.onload = function() {
if (req.status == 200) {
callback(this.responseText);
} else {
callback("Error: " + req.status);
}
}
req.send();
}
getFile(openFile);
<button onclick="getFile(openFile)" >LOAD</button>
<div id="load"></div>