简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>简单教程( www.twle.cn )</title> </head> <body> <h2>内容是数组</h2> <p>内容是数组会转换为 JavaScript 数组</p> <p id="demo"></p> <script> var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myArr = JSON.parse(this.responseText); document.getElementById("demo").innerHTML = myArr[1]; } }; xmlhttp.open("GET", "/r/show/yufei/json/json_demo_array", true); xmlhttp.send(); </script> <p>查看服务端数据 <a href="/r/show/yufei/json/json_demo_array" target="_blank">json_demo_array</a></p> </body> </html>
运行结果: