[英]qooxdoo : XMLHttpRequest Origin null is not allowed by Access-Control-Allow-Origin
I have a qooxdoo project that fetches JSON from an online server using the following codes: 我有一个qooxdoo项目,该项目使用以下代码从在线服务器中获取JSON:
var url = "http://www.example.com/json.php?q=parameter_here";
var store = new qx.data.store.Json(url,"GET", "text/plain");
store.addListener("changeModel", function(ev) {
console.log("changeModel()");
console.log("getData", ev.getData());
});
store.addListener("error", function(ev) {
console.log("error", ev.getData());
});
store.addListener("changeState", function(ev) {
console.log("state", ev.getData());
});
I'm using iMac, and the local path is /Users/SomeUser/Path/To/index.html
我正在使用iMac,本地路径为/Users/SomeUser/Path/To/index.html
I tried to load the index.html
in Chrome browser as usual, but failed, as Chrome blocks the Javascript as Origin null is not allowed by Access-Control-Allow-Origin
. 我试图像往常一样在Chrome浏览器中加载index.html
,但是失败了,因为Chrome阻止了Javascript,因为Origin null is not allowed by Access-Control-Allow-Origin
。 After I read the answer from this question , I know I have to host it in a web server. 阅读此问题的答案后,我知道必须将其托管在Web服务器中。 Therefore I set up a XAMPP for this site. 因此,我为此站点设置了XAMPP。
Since my XAMPP has few existing Alias, I add a new Alias for this site, as follow: 由于XAMPP现有的别名很少,因此我为此站点添加了一个新的别名,如下所示:
<Directory "/Users/SomeUser/Path/To">
Options All
AllowOverride All
Require local
Order allow,deny
Allow from all
</Directory>
Alias /myalias "/Users/SomeUser/Path/To"
When I set up the Alias like this, 403 Forbidden is reported. 当我这样设置Alias时,报告了403 Forbidden。 Then, I found this question on SO, but the answers didn't help. 然后,我在SO上找到了这个问题 ,但是答案没有帮助。 Still 403 Forbidden. 仍然是403禁止。
My goal is to load the site in local XAMPP server. 我的目标是将站点加载到本地XAMPP服务器中。 What did I miss? 我错过了什么? When I upload the folder to a web server online, it works fine. 当我将文件夹在线上传到Web服务器时,它可以正常工作。
In XAMPP Apache error_log
, it shows: 在XAMPP Apache error_log
,它显示:
[Fri Apr 19 17:51:09 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /myalias/index.html denied [2013年4月19日星期五17:51:09] [错误] [客户端127.0.0.1](13)权限被拒绝:拒绝访问/myalias/index.html
For the file, its permission is: 对于文件,其许可为:
drwxr-xrwx 7 SomeUser staff 238 Apr 2 16:48 .
Note: I don't want to change the Chrome launch options to override the Access-Control-Allow-Origin
policy. 注意:我不想更改Chrome启动选项以覆盖Access-Control-Allow-Origin
策略。
您的确意识到,您所要做的就是转到xampp / mamp安装文件夹,找到htdocs文件夹,并在其中创建带有项目的新文件夹(例如测试),然后在浏览器中访问它,例如: http://localhost/test/
对吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.