2013-05-02 95 views
2

嗨我正在通过OAuth 2.0验证用户的过程中,并且在制作时出现Access-Control-Allow-Origin错误(XMLHttpRequest cannot load https://www.box.com/api/oauth2/token. Origin http://localhost is not allowed by Access-Control-Allow-Origin.)以下POST请求:进行HTTP请求时访问控制 - 允许 - 来源错误

var xhr=new XMLHttpRequest(); 
xhr.open('POST',path,true); 
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
xhr.onload = function() { 
    var text = xhr.responseText; 
    alert('Response from request to ' + path + ': ' + text); 
}; 
xhr.onerror = function() { 
    alert('Woops, there was an error making the request.'); 
}; 
xhr.send(params); 

任何帮助将不胜感激!我查看了CORS,JSONP,并添加了回调=?到的网址,但没有我试过正在工作。

回答

1

http://developers.box.com/docs/

盒子API支持上的应用程式 逐个应用程序的基础CORS。如果您正在构建需要CORS的应用程序,请致电 ,并与我们联系,并说明您的使用案例。

+0

ahhh我明白了,非常感谢你指出了这一点 – user2066880 2013-05-02 09:37:57

0

另一种方法是使用YQL,正如他们的开发人员在FAQ中所述。

相关问题