我想通过 AJAX 请求检索我的本地 JSON 文件数据。当我在 Chrome 中启动 html 时,会产生错误:
XMLHttpRequest 无法加载。跨源请求仅支持协议方案:http、data、chrome、chrome-extension、https、chrome-extension-resource。
下面是我的代码:
function getJSON(){
$.ajax({
url: "C:/Users/test/Documents/Demo/KendoTest/testJS/test.json",
type: "GET",
crossDomain: true,
success:function(res){
//do something if successful
},
error:function(e, msg){
alert(JSON.stringify(e) + " " + msg);
}
});
}
如果我添加dataType : 'jsonp',
它返回错误函数。