简体   繁体   中英

AJAX: Access to restricted URI using a Relative Path

Ok what the heck is wrong with this?

xmlhttp.open("POST", "../Module1/page1.html", true);
xmlhttp.send(null);

Throws NS_ERROR_DOM_BAD_URI: Access to restricted URI denied When I try to load the page, everything is running locally, using Firefox 24.

I can't use any backend server languages when this gets used online, either, so no PHP or ASP solutions will work. Hooray LMS SCORM content. :U

Now I can do this just fine:

xmlhttp.open("POST", "page1.html", true);
xmlhttp.send(null);

Its just that it won't let me load a page in another directory.

This is apparently due to cross domain access restriction. When you use relative paths like /myApplication.html the request is send to the same domain where your parent application is placed/hosted. To solve this issue you can use reverse proxy method if you are using Apache.

http://geronimo.apache.org/GMOxDOC11/configure-apache-httpd-as-a-reverse-proxy-modproxy.html

or

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

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