Im using a javscript file to read JSON data and send them to my html file, everything is in a file, nothing is on a server, but it wont work, error syntax:
Access to XMLHttpRequest at 'file:///C:/Users/USER/Desktop/Websites/PROMO%20CODES/jpr.JSON' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
index.js:10 GET file:///C:/Users/USER/Desktop/Websites/PROMO%20CODES/jpr.JSON net::ERR_FAILED
MY CODE
function getData() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj.name;
}
};
xmlhttp.open("GET", "jpr.JSON", true);
xmlhttp.send();
}