我正在研究一个小的Chrome扩展,它将调用Remember the Milk API。谷歌有一个使用Flikr API的good example,我将它用作我的扩展的基础。他们的例子在我的浏览器(Linux上最新的Chrome)上完美运行。从Chrome扩展中的JavaScript调用网站API时出现跨域错误
当我换出记住牛奶API方法名称和API密钥,不过,我发现了以下错误:
XMLHttpRequest cannot load http://api.rememberthemilk.com/services/rest/?method=rtm.test.echo&api_key=xxxxxxxxxxxxxxxxxxxxxx&name=Test%20task.
Origin chrome-extension://lifnmciajdfhj is not allowed by Access-Control-Allow-Origin.
我的代码如下所示:
var req = new XMLHttpRequest();
req.open(
"GET",
"http://api.rememberthemilk.com/services/rest/?" +
"method=rtm.test.echo&" +
"api_key=xxxxxxxxxxxxxxxxxxxxxxxxxx&" +
"name=Test%20task",
true);
req.onload = onResponseReceived;
req.send(null);
function onResponseReceived() {
console.log("It worked.");
}
任何建议?