1.html:
show2.html
学号 | 姓名 | 年龄 | 住址 |
---|
2.js
//浏览器协议var xmlHttp;function creatXMLHttpRequest(){ if(window.xmlHttpRequest){ xmlHttp=new XMLHttpRequest(); }else if(window.ActiveXObject){ xmlHttp=new XMLHttpRequest("Microsoft,XMLHTTP"); }}//触发函数function Student2(){ alert("aa"); //建立异步请求对象 creatXMLHttpRequest(); //开启对服务器端的连接 xmlHttp.open("post","student2.txt",true); //向浏览器发送请求 xmlHttp.send(); //调用回调函数 xmlHttp.onreadystatechange=getStudent2; }function getStudent2(){ //判断请求状态 if(xmlHttp.readyState==4&&xmlHttp.status==200){ //服务器传来的响应 var msg=xmlHttp.responseText; var stus=eval("("+msg+")"); tbody=document.getElementById("main"); for(var i=0;i
3.txt
[
{"stuNo":"001","name":"jack","age":23,"address":"beijing"},{"stuNo":"002","name":"bob","age":24,"address":"shanghai"},{"stuNo":"003","name":"mary","age":26,"address":"anerick"},{"stuNo":"004","name":"kity","age":26,"address":"hongkong"}]