[英]Origin null is not allowed by access-control-allow-origin on Chrome
I'm developing a website to be used from a DVD, so I cannot rely on http://
protocol.我正在开发一个要从 DVD 使用的网站,所以我不能依赖
http://
协议。 The HTML pages use jQuery and knockout.js and load data from the JSON file using $.getJSON
. HTML 页面使用jQuery 和knockout.js,并使用
$.getJSON
从JSON 文件加载数据。
This runs fine on Firefox but I get an origin null is not allowed by access-control-allow-origin
on Chrome.这在 Firefox 上运行良好,但我在 Chrome 上的
origin null is not allowed by access-control-allow-origin
。 I've looked many SO answers on this but I cannot force the users to start Chrome using additional command line parameters or putting the site on HTTP web server.我已经看过很多关于此的 SO 答案,但我无法强制用户使用其他命令行参数或将站点放在 HTTP Web 服务器上来启动 Chrome。
Is there a way to let Chrome open local files?有没有办法让 Chrome 打开本地文件?
I know this might be late, but I in the mist of a similiar problem.我知道这可能会迟到,但我陷入了类似问题的迷雾中。 I have a solution for JSON (which I will share), but not for XML.
我有一个针对 JSON 的解决方案(我将分享),但没有针对 XML 的解决方案。
My solution was to use a javascript loader (ex: HeadJS) which does a great job for an application needing to run offline.我的解决方案是使用 javascript 加载器(例如:HeadJS),它对于需要离线运行的应用程序非常有用。 I would create a file with .js in this manner.
我会以这种方式用 .js 创建一个文件。
var JSON = {
Field1: "Text",
Field2: "Text2"
}
Then I would use the loader.然后我会使用装载机。 We actually allowed the user to choose which data they wanted and loaded that particular file.
我们实际上允许用户选择他们想要的数据并加载该特定文件。
Hope this help someone else.希望这对其他人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.