我想提出一个GET调用Foursquare的OAuth的URL。浏览器控制台打印以下错误Foursquare的回报“没有访问控制允许起源”头存在错误
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.
这里是进行调用的代码片段:
$http.get(url).success(function(data,status,headers,config){
});
但是,如果我链接按钮,这个URL,浏览器需要我的认证页面。
这有什么区别?当URL链接到一个按钮,为什么它是工作,为什么当GET调用该URL使得它不工作?
阅读有关CORS。在这种情况下,您将无法使用AJAX。 – dfsq