I am creating an excel web addin by javascipt with in SSL certificate.
now I want to send a get-resquest (http) to get data.(not https)
I found this article: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/addressing-same-origin-policy-limitations but I still don't know how to code,are there some demos?
function getdata() {
Excel.run(function(context) {
if(document.getElementById("theniubikey")) {
head.removeChild(script); //删除临时添加的script标签
}
var script = document.createElement("script");
script.type = "text/javascript";
script.id = "theniubikey";
var url="http://127.0.0.1/api/getdata/10001";
script.setAttribute(
"src",
url + "?alt=json-in-script&callback=jsonpCallback"
);
document.getElementsByTagName("head")[0].appendChild(script);
// return context.sync();
return context.sync().then(
(window.jsonpCallback = function(data) {
//document.getElementById("textareaid").innerHTML = data.length();
document.getElementById("textareaid").innerHTML = JSON.stringify(data);
return data;
})
);
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
}