我在 javaScript 中有一个实验的在线实现,它必须从 JSON 文件加载任务实现的参数。我找到了一种方法来做到这一点,但它只有在我通过实时服务器运行任务时才有效。如果我通过打开 index.html 文件在本地运行,则会收到以下错误:
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).
我加载 JSON 文件的代码是:
$.ajax({
dataType: "json",
url: "config.json",
success: function(data) {
assignValues(data); // extract vals from JSON file
main(); // run experiment
}
});
有什么建议么?谢谢你。
海绵宝宝撒
相关分类