您好,我正在通过 OAuth 2.0 对用户进行身份验证,并且XMLHttpRequest cannot load https://www.box.com/api/oauth2/token. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
在发出以下 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 并添加了 callback=? 到网址,但我尝试过的没有任何工作。