I am trying to fetch 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 have requested the permission to cross-origin 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, it still gives me an error saying:
XMLHttpRequest cannot load http://weather.yahooapis.com/forecastrss?w=2502265&u=c. Origin chrome-extension://randomid is not allowed by Access-Control-Allow-Origin.
And I can't think of any reason why this is happening. Any idea?