简体   繁体   English

jQuery函数上的Access-Control-Allow-Origin不允许

[英]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: 当我通过Firebug检查时,出现此错误:

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. 最好的选择是在本地计算机上使用简单的Web服务器来服务您的页面。

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. 出于安全原因,浏览器不允许file:///协议进行AJAX调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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