I've been working on an online experiment using JavaScript, and I need to load parameters for the task from a JSON file. I managed to do this successfully when running the task through a live server. However, if I try to run it locally by opening the index.html file, I encounter the following error:
Cross-Origin Request Blocked: The Same Origin Policy prevents reading the remote resource at file:///home/terraregina/Desktop/Space_Adv_Behav_PIlot_Online/config.json. (Reason: CORS request not http).
Here's my code for loading the JSON file:
$.ajax({
dataType: "json",
url: "config.json",
success: function(data) {
assignValues(data); // extracting values from JSON file
main(); // executing the experiment
}
});
Do you have any suggestions or solutions? Thank you.