<!DOCTYPE html>
<html>
<body>
<h2>内容作为数组。</h2>
<p>作为 JSON 数组编写的内容将被转换为 JavaScript 数组。</p>
<p id="demo"></p>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myArr[0];
}
};
xmlhttp.open("GET", "json_demo_array.txt", true);
xmlhttp.send();
</script>
<p>看看 <a href="json_demo_array.txt" target="_blank">json_demo_array.txt</a></p>
</body>
</html>