dechrimi
dechrimi

Reputation: 3

not allowed by Access-Control-Allow-Origin

If I run this Code:

function sendRequest() {
  var req = new XMLHttpRequest();
  req.open("GET", "http://www.google.com/search?XXXX", true);
  req.onreadystatechange = function() {
      if (req.readyState == 4) {
        if (req.status == 200) {
          alert( req.responseText );
        }
      }
    };
  req.send();
}

I get this error:

XMLHttpRequest cannot load http://www.google.com/search?XXXX. Origin chrome-extension://loifkhcbcjakjhcmecadcbdgfldfjfce is not allowed by Access-Control-Allow-Origin.

why?? In manifest file I have:

"permissions": [
    "<all_urls>"
]

Demi

Upvotes: 0

Views: 1630

Answers (1)

Marius Kjeldahl
Marius Kjeldahl

Reputation: 6824

That will work for a packaged Chrome app, but not a hosted one.

Upvotes: 1

Related Questions