W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>数组内容</h1> <p>以 JSON 数组写的内容会被转换为 JavaScript 数组。</p> <p id="demo"></p> <script> const xmlhttp = new XMLHttpRequest(); xmlhttp.onload = function() { const myArr = JSON.parse(this.responseText); document.getElementById("demo").innerHTML = myArr[0]; } xmlhttp.open("GET", "/demo/js/json_array.txt", true); xmlhttp.send(); </script> <p>查看 <a href="/demo/js/json_array.txt" target="_blank">json_array.txt</a></p> </body> </html>