Javascript 发出HTTP请求时的访问控制允许源错误
您好,我正在通过OAuth 2.0对用户进行身份验证,我得到一个访问控制允许源错误(Javascript 发出HTTP请求时的访问控制允许源错误,javascript,jquery,html,oauth-2.0,box-api,Javascript,Jquery,Html,Oauth 2.0,Box Api,您好,我正在通过OAuth 2.0对用户进行身份验证,我得到一个访问控制允许源错误(XMLHttpRequest无法加载)https://www.box.com/api/oauth2/token. 起源http://localhost 在发出以下POST请求时,Access Control Allow Origin.)不允许使用: var xhr=new XMLHttpRequest(); xhr.open('POST',path,true); xhr.setRequestHeader("Con
XMLHttpRequest无法加载)https://www.box.com/api/oauth2/token. 起源http://localhost 在发出以下POST请求时,Access Control Allow Origin.
)不允许使用:
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和添加回调=?到url,但我尝试过的都不起作用。
Box API支持服务器上的CORS
以应用程序为基础。如果您正在构建需要CORS的应用程序,
请联系我们,说明您的用例
另一种方法是按照他们的开发人员在FAQ中描述的方式使用