jeudi 5 février 2015

Call Chrome-Extension Method from within options page?


I wrote a chrome extension for a specific website. If the extension is installed and I navigate to that site "example.com", my extension calls the following method:



var search="john";
$.get("http://ift.tt/16Id9FQ"+search, function (data) {
console.log(data);
});


That works just fine.


Now I have to call the same method from within the options-page of that extension. When I do that, I receive the following error:



XMLHttpRequest cannot load http://ift.tt/16Id7Op. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.



I understand why this happens but have to find a way to get around this. My idea is to trigger the Extension-Script to call the method and then return the results to the options page. I expect, chrome.runtime.sendMessage() isn't help here.


Needless to say: That domain is not hosted by me, so I can't just change the header.





Aucun commentaire:

Enregistrer un commentaire