我似乎无法请求这个url:"https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dogs" from my popup.html.
我:
XMLHttpRequest无法加载https://ajax.googleapis.com/ajax/services/search/web?q = v = 1.0,狗。Origin chrome-extension://nemobemncffjipfgpaffgiigbjhkpden不被Access-Control-Allow-Origin允许
这是我的清单:
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"popup":"popup.html"
},
"permissions": [
"tabs","http://*/","https://*/"
]
}
和我的代码
$.ajax({
type: 'GET', //making a get request
url: "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dogs",
success: function (data) {
document.write(data);
}
});
请帮忙,谢谢
查看我的manifest.json中的权限列:
"permissions": ["tabs", "notifications", "http://*/*", "https://*/*"],
所以你的url模式是错误的,它应该是"http:///",而不是"http://*/"。