我正在研究一個小的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.");
}
任何建議?