简体   繁体   English

XMLHttpRequest错误:Access-Control-Allow-Origin不允许起源

[英]XMLHttpRequest error: Origin not allowed by Access-Control-Allow-Origin

Basically I want to create an AddOn for Firefox which will fetch only RSS feeds from particular website. 基本上,我想为Firefox创建一个插件,它将仅从特定网站获取RSS提要。 But I am getting an error: 但我收到一个错误:

XMLHttpRequest cannot load http://www.- ** Origin http://localhost:59382 is not allowed by Access-Control-Allow-Origin. XMLHttpRequest无法加载http://www.- ** Access-Control-Allow-Origin不允许使用原始http://localhost:59382

Can anyone explain how to resolve this error? 谁能解释如何解决此错误?

Same-origin policy applies to web content, but cross-domain requests are possible in FF add-ons. 同源策略适用于Web内容,但是在FF附件中可能会出现跨域请求。 See here and here for two ways of accomplishing this. 请参见此处此处以了解完成此操作的两种方法。

ps: If you are interested, there are some nifty ways to do cross-site requests in plain old sites, using YQL (yahoo query language) (and here ) and even CSSHttpRequest (I haven't tried the latter, but I've seen some cool demos). ps:如果您有兴趣,可以使用一些简单的方法在普通的旧站点中进行跨站点请求, 使用YQL(雅虎查询语言) (和此处 )甚至CSSHttpRequest (我还没有尝试过后者 ,但是我已经看到一些很酷的演示)。

it's the classic cross-origin problem. 这是经典的跨域问题。 You migth want to read this article too. 您也想阅读这篇文章

Good Luck 祝好运

You can't use the normal xhr from one domain to another. 您不能使用从一个域到另一个域的普通xhr。 You need to use the new XHR or the one speciall made for addons. 您需要使用新的XHR或附加组件专用的一个。 If you're on GM, it's the one starting with GM_* 如果您使用的是GM,则以GM_ *开头

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

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