Question

I cant seem to request this url: "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dogs" from my popup.html.

I'm getting:

XMLHttpRequest cannot load https://ajax.googleapis.com/ajax/services/search/web? v=1.0&q=dogs. Origin chrome-extension://nemobemncffjipfgpaffgiigbjhkpden is not allowed by Access-Control-Allow-Origin.

Here is my manifest:

{
"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://*/"
]
}

and my code:

$.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);
            }
            });

Help please, thanks.

Was it helpful?

Solution

Look at the permission column in my manifest.json:

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

So, your url pattern is wrong, it should be "http:///", not "http://*/".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top