Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 发出HTTP请求时的访问控制允许源错误_Javascript_Jquery_Html_Oauth 2.0_Box Api - Fatal编程技术网

Javascript 发出HTTP请求时的访问控制允许源错误

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

您好,我正在通过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("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中描述的方式使用