简体   繁体   中英

not allowed by Access-Control-Allow-Origin on jQuery function

I try work this code but not working.

$(".edit").click(function(){
$(".edit").load("another.html #user_adr");
})

When i check via Firebug, get this error:

XMLHttpRequest cannot load file://localhost/Users/Desktop/site-new/another.html. Origin null is not allowed by Access-Control-Allow-Origin.

How can i fix it?

Browsers have recently started treating calls to other files on the local file system as cross domain requests. Calling pages from other domains is banned by default security settings, and that's what you're running into.

Your best bet is to use a simple web server on your local machine to serve your pages instead.

No. you are performing cross-domain request . you cant do cross domain request without proper access mechanism. Cross Orgin Resource sharing

  1. You need a webserver to serve the request. you cannot load the file from file protocol.
  2. browers don't allow file:/// protocol for AJAX calls for security reasons.

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