Origin not Allowed by Access-Control-Allow-Origin?

I'm trying to get weather information from Yahoo using XHR in a Chrome extension:

$.ajax({
    url: "https://weather.yahooapis.com/forecastrss?w=" + 250226 + "&u=c",
    dataType: 'xml',
    success: function(data) {
        console.log(data);
    }
});

      

and I requested cross origin permission using this script:

$("button").click(function(){
    chrome.permissions.request({
        origins: ['*://weather.yahooapis.com/*']
    }, function(granted) {
        if (granted) {
            console.log("Success creating permission.");   //successful
    } else {
            console.log("Not successful.");
    }
});

      

However, this still gives me an error:

XMLHttpRequest cannot load http://weather.yahooapis.com/forecastrss?w=2502265&u=c. Origin chrome-extension://randomid is not allowed by Access-Control-Allow-Origin.

enter image description here

And I can't think of any reason why this is happening. Any idea?

+3


source to share


1 answer


Does your Chrome extension have a manifest file? It looks like this is a problem, you must also set the cross origin permission.



It looks like the mention of randomId is due to the extension not being assigned its own extension ID.

0


source







All Articles