While delving into learning JSON and AJAX, I encountered a challenge when trying to load a simple JSON file from a repository on GitHub.
To set up a local server, I am utilizing browser sync along with the following code snippet:
var request = new XMLHttpRequest();
request.open(
"GET",
"https://github.com/d-ivashchuk/misc/blob/master/ancestry.json",
false
);
request.onload = function() {
var data = JSON.parse(request.responseText);
console.log(data[3]);
};
request.send();
The issue arises as follows:
Failed to load. No 'Access-Control-Allow-Origin' header is present on the resource.
Although I have successfully downloaded some JSON files from GitHub previously, I am still keen on finding a solution to this particular problem.