Closed tomasantunes closed 7 years ago
@tomasantunes I'm not a big user of jQuery but there is probably a parameter you can pass to allow cross origin or possibly you are using an old version of jQuery as it should allow cross origin to file:// paths.
You can just use regular AJAX code:
var request = new XMLHttpRequest();
request.open("GET", "file://" + data.localPath + "/file.json", true);
request.onreadystatechange = function() {//Call a function when the state changes.
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
// returns a plain string
alert('data: ' + data);
// convert string data to an Object.
var obj = JSON.parse(data);
}
}
}
request.send();
Closing, no response in a month.
I'm trying to read a downloaded json file but I get a cross origin error.
My code is: