【发布时间】:2016-08-02 23:07:47
【问题描述】:
我正在尝试从我的 excel 插件发出跨域请求, 正如这里所建议的那样:http://dev.office.com/docs/add-ins/develop/addressing-same-origin-policy-limitations
我正在尝试实现一个 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 页面,结果没有任何错误
【问题讨论】:
标签: javascript excel office-js