以下是我正在尝试vis.js的代码。我正在尝试通过xmlhttprequest可视化以json格式显示在服务器上的数据。但它显示的只是空白屏幕作为输出。我在服务器上运行以下代码。响应显示状态200和空白屏幕
<html>
<head>
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"
></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.19.1/vis.min.js"
></script>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.19.1/vis.min.css"
rel="stylesheet"
type="text/css"
/>
<style type="text/css">
#mynetwork {
width: 800px;
height: 800px;
border: 1px solid rgb(134, 29, 29);
}
</style>
</head>
<body>
<div id="testdiv"></div>
<div id="mynetwork"></div>
<script type="text/javascript">
// function loadXMLDoc() {
var xhttp = new XMLHttpRequest();
//var xhttp = new ActiveXObject("MSXML2.XMLHTTP");
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//var data1 = this.responseText;
console.log(xhttp.responseText);
var data1 = JSON.parse(xhttp.responseText);
document.getElementById("testdiv").innerHTML =
"<h1>Data Export Successful</h1>";
}
//};
xhttp.open("GET", "http://127.0.0.1:5000/neo4j/export", true);
xhttp.setRequestHeader("Access-Control-Allow-Origin", "*");
xttp.setRequestHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type,Accept"
);
//loadXMLDoc();
xhttp.send();
};
var data = {};
var options = {};
var container = document.getElementById("mynetwork");
var network = new vis.Network(container, data, options);
</script>
</body>
</html>