Following is the code I tested.
Code:
$.ajax({
url : 'https://github.com/sab99r/Indian-States-And-Districts/blob/master/states-and-districts.json',
type : 'GET',
datatype : 'json',
header: {
'Access-Control-Allow-Origin': 'https://github.com'
}
.done(function(response)){
data = JSON.parse(response);
loadlog(data);
}
});
Following is the error I am receiving when running the above code.
Error:
Access to XMLHttpRequest at 'https://github.com/somelink/data.json' from origin 'http://127.0.0.1:3000' \ has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have looked into many resources, also.
Resource #1
Resource #2
Can somebody explain the reason for the above error, please?