简体   繁体   中英

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:

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

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 . After I read the answer from this question , I know I have to host it in a web server. Therefore I set up a XAMPP for this site.

Since my XAMPP has few existing Alias, I add a new Alias for this site, as follow:

<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. Then, I found this question on SO, but the answers didn't help. Still 403 Forbidden.

My goal is to load the site in local XAMPP server. What did I miss? When I upload the folder to a web server online, it works fine.

In XAMPP Apache error_log , it shows:

[Fri Apr 19 17:51:09 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /myalias/index.html denied

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.

您的确意识到,您所要做的就是转到xampp / mamp安装文件夹,找到htdocs文件夹,并在其中创建带有项目的新文件夹(例如测试),然后在浏览器中访问它,例如: http://localhost/test/对吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM