本质上,我有一个自定义的HTML图表,需要来自外部安全代理服务器的值。现在,我将HTML块插入页面上的相关区域,包括JavaScript以通过XHTTP GET请求获取正确的数据。安全的JavaScript GET请求
直到我们限制访问我们的代理服务器以限制从我们的C5站点(这也是我们想要的)的SSL时,它才有效。
这可以防止图表获得正确的值,因为HTML和JavaScript会在客户端执行而不是通过C5执行。
本质上,我需要做的(我认为)是在C5内部移动GET请求,以便它可以通过SSL证书。然后我需要把这个值放回到图表中。
下面是一些基于HTML代码的伪代码,我目前正在进入该页面。
<!-- This is the actual HTML block that I'm creating. -->
<div id="HTMLBlock455" class="HTMLBlock">
<div class="someCustomChart">
<!-- Here's the script currently running that gets the necessary data and calls the proper functions to populate the chart. -->
<script type="text/javascript">
// Global Var to store updating value
var amount = 0;
// Open a new HTTP Request)
var xhr = new XMLHttpRequest();
xhr.open("GET", "Some_ElasticSearch Server", true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var person = JSON.parse(xhr.responseText);
amount = person._source.age; // Grabs the person age
$('#chart_328').data('updateto', amount); //updates the above HTML data value
document.getElementById('chart_328_text').innerHTML = amount + '%';
} else {
console.error(xhr.statusText);
}
}
};
xhr.onerror = function (e) {
console.error(xhr.statusText);
};
xhr.send(null);
// This function executes on page load and prepares the chart!
$(document).ready(function() {
....
}
难道您不能在服务器上反弹请求,实质上是使用它作为代理吗? –
欢迎来到SO @sethmrtn。为了满足SO的要求(我们不提问问题,我们试图让它们重用),我已经编辑了你的问题。 –
什么是C5网站,为什么不能向它发送GET请求?它没有实施CORS?什么是路障? –