开发者

Chrome Extension, Jquery ajax failed

开发者 https://www.devze.com 2023-03-05 18:30 出处:网络
I\'m tryingto write myself a chrome extension, and I have the following lines in it that seem to be failing:

I'm trying to write myself a chrome extension, and I have the following lines in it that seem to be failing:

fk_url = "http://www.flipkart.com/search-books?query=" + search + "algorithms&from=a开发者_运维技巧ll";
$.get(fk_url);

And, when my extension is run, it gives me this error:

XMLHttpRequest cannot load http://www.flipkart.com/search-books?query=algorithmsalgorithms&from=all. Origin chrome-extension://cpepfejkgdnhemablbikonijfjnjmnha is not allowed by Access-Control-Allow-Origin.

I'm totally lost as to how I can fix this. Any help? (The website I'm trying to connect to does not offer an API)


Your manifest.json file should have the domain you're looking to use in the permissions:

"permissions": [
    "http://*.flipkart.com/"
]


If they don't offer an API, you're pretty much out of luck with a Chrome extension, I'm afraid. You can't just AJAX-request any resources from any domain (unless they allow you access: https://developer.mozilla.org/en/http_access_control).

For more details, read http://en.wikipedia.org/wiki/Same_origin_policy

0

精彩评论

暂无评论...
验证码 换一张
取 消