Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.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 office excel将CORS请求作为跨域请求_Javascript_Excel_Office Js - Fatal编程技术网

Javascript office excel将CORS请求作为跨域请求

Javascript office excel将CORS请求作为跨域请求,javascript,excel,office-js,Javascript,Excel,Office Js,我正在尝试从我的excel插件发出跨域请求, 正如这里所建议的: 我正在尝试实现cors请求。 然而,每当我试图打开我的请求时,我都会收到一个拒绝访问错误 我在这里使用的代码尝试打开一个连接,但是在这里我已经得到了错误 var xhr = new XMLHttpRequest(); xhr.open('GET', 'url'); //this line gives an acces denied error. xhr.onload = function(e) { } xhr.s

我正在尝试从我的excel插件发出跨域请求, 正如这里所建议的:

我正在尝试实现cors请求。 然而,每当我试图打开我的请求时,我都会收到一个拒绝访问错误

我在这里使用的代码尝试打开一个连接,但是在这里我已经得到了错误

 var xhr = new XMLHttpRequest();
xhr.open('GET', 'url'); //this line gives an acces denied error.
xhr.onload = function(e) {   

    }
xhr.send();
有人能告诉我是否可以在excel中实现cors请求吗

ajax代码还提供了一个错误对象

    $.ajax({
    type: 'GET',
    url: 'remoteurl',
    cache: true, 

    },
    success: function (result) {
        functionAfterLoad(JSON.parse(JSON.stringify(eval("(" +result + ")"))));

    },
    error: function(result) {
        console.error('Error while retrieving funnel HTML', result);
    },

});
但是,当我打电话给:

    $.ajax({
    type: 'GET',
    url: window.location.href ,
    cache: true, 

    },
    success: function (result) {
        functionAfterLoad(JSON.parse(JSON.stringify(eval("(" +result + ")"))));

    },
    error: function(result) {
        console.error('Error while retrieving funnel HTML', result);
    },

});

因此,我得到了没有任何错误的html页面,

提供了一些关于在客户端发出CORS请求的好技巧。很多CORS设置都是在服务器上完成的,但是假设服务器设置为允许您的请求,您可能只需要包括
xhr.withCredentials=true
在您的
打开之前
调用。

Hey@leetibbett我得到了一个运行时错误,访问被拒绝,即使我添加了xhr.withCredentials=true;你的IE设置允许CORS吗?请参阅中的答案以了解“从何处开始”是“我的ie设置允许CORS”,但是我不知道excel webview是否使用了所有ie设置?这是您的响应错误的样子:Origin ms appx web://未在Access Control allow Origin标头中找到。XMLHttpRequest:Network Error 0x80070005,访问被拒绝。我在这里的示例中添加了一个ajax get。我得到一个包含错误的错误对象:Acces DENITED作为错误文本