Title

woshi a

window.function () {

getData();

}

//1.11请求数据

function getData() {

if(window.XMLHttpRequest){

var XHR = new XMLHttpRequest()

}else{

var XHR = new ActiveXObject("Microsoft.XMLHTTP")

}

//1.12 打开ajax对象3参数(请求方式,请求地址,同步(flase)异步(ture)布尔值)

XHR.open("get","/login.do",true)

//1.3 AJAX 结束请求

XHR.send()

XHR.onreadystatechange=function () {

if(XHR.readyState==4&&XHR.status==200){

let arr=JSON.parse(XHR.responseText)

onloadIndex(arr)

}

}

//1.4利用AJAX 对象发送对象

}

function onloadIndex(arr) {

$("#student thead>tr").html("");

$("#student tbody").html("");

for(item in arr[0]){

$("#student thead>tr").append(`

${item}`);

}

arr.forEach((item)=>{

$("#student tbody").append(`

${item['序号']}${item['姓名']}${item['年龄']}${item['性别']}${item['学号']}

删除

修改

`)

})

}

function deleBtn(stuId){

if(window.XMLHttpRequest){

var XHR = new XMLHttpRequest()

}else{

var XHR = new ActiveXObject("Microsoft.XMLHTTP")

}

XHR.open("post","/login_one.do",true)

XHR.setRequestHeader("content-type","application/x-www-form-urlencoded")

XHR.send("stuId="+stuId);

XHR.onreadystatechange=function () {

if(XHR.readyState==4&&XHR.status==200){

let stu=Boolean(XHR.responseText)

if(stu){

getData()

}else{

alert("删除失败")

}

}

}

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐