【发布时间】:2014-12-21 19:49:56
【问题描述】:
我正在对foursquare OAuth URL 进行GET 调用。浏览器控制台打印如下错误
XMLHttpRequest cannot load https://foursquare.com/oauth2/authenticate?client_id=DF4I1TGNVHAM40PDLOHZQZ…onse_type=code&redirect_uri=http://localhost:9000/auth/foursquare/callback. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
这里是发出呼叫的 sn-p:
$http.get(url).success(function(data,status,headers,config){
});
但如果我将一个按钮链接到此 url,浏览器会将我带到身份验证页面。
它有什么不同?为什么当 URL 链接到按钮时它可以工作,为什么当对该 URL 进行 GET 调用时它不工作?
【问题讨论】:
-
了解 CORS。在这种情况下,您将无法使用 AJAX。
标签: javascript angularjs xmlhttprequest foursquare