I have an online implementation of an experiment in javaScript and it has to load the parameters for the task implementation from a JSON file. I found a way to do this but it works only when I run the task through a live server. If I run locally by opening the index.html file, I get the following error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/terraregina/Desktop/Space_Adv_Behav_PIlot_Online/config.json. (Reason: CORS request not http).
My code for loading the JSON file is:
$.ajax({
dataType: "json",
url: "config.json",
success: function(data) {
assignValues(data); // extract vals from JSON file
main(); // run experiment
}
});
Any suggestions? Thank you.