我编写了以下代码,该代码可以在旧的Internet Explorer上很好地运行,但不能在Firefox,Chrome,Edge等上运行。这是否是我通过http而不是https导入json的问题?如果是这样,我该如何调整呢?任何帮助表示赞赏!
<head>
<script>
var myObj, x, txt = "";
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText);
txt += "<table border='1'>"
for (x in myObj.Data) {
txt += "<tr><td>" + myObj.Data[x].Name + "</td></tr>";
}
txt += "</table>"
document.getElementById("demo").innerHTML = txt;
}
}
xmlhttp.open("GET", "http://134.255.254.137/Data.json");
xmlhttp.send();
</script>
</head>
<html>
<body>
<div class="container">
<h2>Daten aus JSON-Datei:</h2>
<div id="demo">
</div>
</div>
</body>
</html>