Chrome不允许向允许的域发送Ajax请求

问题描述:

我正在创建我的第一个Chrome扩展程序,这是一个相对简单的扩展程序,带有一些Ajax调用。

I'm creating my first Chrome extension, a relatively simple one with some ajax calls.

我的清单很简单:

My manifest is pretty simple:

{
    "name": "Read It Now",
    "version": "0.12",
    "description": "Read it now.",
    "permissions": [
                    "https://readitlaterlist.com"
                   ],
  "app": {
      "launch": {
          "local_path": "index.html"
      }
  }
}

然后我使用jQuery获取一些简单来自以下网址的数据:

I'm then using jQuery to fetch some simple data from a URL like:

https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz

然而,Chrome仍然拒绝它:

However, Chrome still rejects it:


XMLHttpRequest无法加载
https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yy Y'安培;密码= ZZZ
Origin chrome-extension:// cdfeahailioembamnjnikbiemengfgpp不是
允许的Access-Control-Allow-Origin。

XMLHttpRequest cannot load https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz. Origin chrome-extension://cdfeahailioembamnjnikbiemengfgpp is not allowed by Access-Control-Allow-Origin.


您必须在 URL匹配中包含路径格式https://readitlaterlist.com/*应该解决您的问题。

You have to include the path in your URL match pattern. "https://readitlaterlist.com/*" should fix your problem.