W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>数组内容</h1> <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", "/example/json/json_demo_array.txt", true); xmlhttp.send(); </script> <p>查看 <a href="/example/json/json_demo_array.txt" target="_blank">json_demo_array.txt</a></p> </body> </html>