通过文件加载本地JSON文件://触发跨域空出身违规行为,解决方案吗? (jQuery的) [英] Load local JSON files via file:// triggers cross-domain null origin violation, solution? (jQuery)
问题描述
我有一个网页,我想在本地使用,没有一个Web服务器,只需在浏览器中打开本地HTML文件。本网页有关的数据加载,通过jQuery的的getJSON()方法,如:
I have a webpage I'd like to use locally, without a web server, by simply opening the local HTML file in my browser. This webpage in question loads data via jQuery's getJson() method, as in:
$.getJSON("mydata.json", function(j) {
...
的JSON文件也是本地的,并且被存储在相同的目录中的网页。当我尝试使用的页面,我得到:
The JSON files are also local, and are stored in the same directory as the webpage. When I attempt to use the page, I get:
原产地空没有被允许访问控制 - 允许 - 产地。
(铬6 OS X,在Firefox和Safari浏览器类似的错误)。
(Chrome 6 OS X, similar errors in Firefox and Safari).
有没有解决这个办法吗?是否有可能从本地文件加载JSON?谢谢!
Is there any way around this? Is it possible to load JSON from local files? Thanks!
推荐答案
试着用运行Chrome浏览器 - 让文件存取的档案
这篇关于通过文件加载本地JSON文件://触发跨域空出身违规行为,解决方案吗? (jQuery的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!