这段代码在FF和IE中运行良好,但在Chrome中却不行。为什么?
$(document).ready(function(){
$.getJSON("timline.js",function(result){
alert(result);
});
});chrome错误:加载资源失败: Access-Control-Allow-Origin不允许Origin为空。file:///E:/jquery/parekh_timeline/timline.js
XMLHttpRequest无法加载file:///E:/jquery/parekh_timeline/timline.js.Access-Control-Allow-Origin不允许Origin为空。
发布于 2014-01-30 17:49:06
它是著名的Chrome bug。
运行本地web服务器并使用localhost。我使用的是SimpleHTTPServer python模块:
python -m SimpleHTTPServer或者使用Chrome标志--allow-file-access-from-files。
发布于 2014-01-30 17:47:09
您需要在web服务器上托管您的文件。
https://stackoverflow.com/questions/21452816
复制相似问题