1

ポップアップ.htmlから「https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dogs」というURLをリクエストできないようです。

私が得ている:

XMLHttpRequestはhttps://ajax.googleapis.com/ajax/services/search/webを読み込めませんか?v = 1.0&q=dogs。Origin chrome-extension:// nemobemncffjipfgpaffgiigbjhkpdenは、Access-Control-Allow-Originでは許可されていません。

これが私のマニフェストです:

{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"popup":"popup.html"
},
"permissions": [
"tabs","http://*/","https://*/"
]
}

と私のコード:

$.ajax({
            type: 'GET', //making a get request
            url:   "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dogs",
            success: function (data) {
              document.write(data);
            }
            });

助けてください、ありがとう。

4

1 に答える 1

4

私のmanifest.jsonの権限列を見てください:

"permissions": ["tabs", "notifications", "http://*/*", "https://*/*"],

したがって、URLパターンが間違っています。 「http:// * /」ではなく「http:///」である必要があります。

于 2011-12-26T10:45:12.480 に答える