如果我运行此代码:
function sendRequest() {
var req = new XMLHttpRequest();
req.open("GET", "http://www.google.com/search?XXXX", true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
alert( req.responseText );
}
}
};
req.send();
}
我收到此错误:
XMLHttpRequest cannot load http://www.google.com/search?XXXX. Origin chrome-extension://loifkhcbcjakjhcmecadcbdgfldfjfce is not allowed by Access-Control-Allow-Origin.
为什么? 在清单文件中我有:
"permissions": [
"<all_urls>"
]
黛咪
答案 0 :(得分:1)
这适用于打包的Chrome应用,但不适用于托管的应用。