Ajax异步加载

#JavaScript

今天选课,居然有同学拿脚本来选!!!还故意多选,这实在有点不公平(ㆀ˘・з・˘) 为了抓住别人退选的机会,咳咳,那就比一下谁的脚本快了 Ajax即异步加载JavaScript和xml,有什么用呢,主要是在不刷新页面的情况下与服务器交换数据。。。 使用如下: let urlList = new Array(3); urlList[0] = "http://xk.urp.***.edu.cn/jw_css/xk/runSelectclassSelectionAction.action?select_jxbbh=22223051201830000&select_xkkclx=11&select_jhkcdm=22223051"; urlList[1] = "http://xk.urp.***.edu.cn/jw_css/xk/runSelectclassSelectionAction.action?select_jxbbh=22213050201830000&select_xkkclx=11&select_jhkcdm=22213050"; urlList[2] = "http://xk.urp.***.edu.cn/jw_css/xk/runSelectclassSelectionAction.action?select_jxbbh=22123080201830000&select_xkkclx=11&select_jhkcdm=22123080"; let reqList = new Array(3); for (let i = 0; i < 3; i++) { reqList[i] = new XMLHttpRequest(); reqList[i].onreadystatechange = function() { if (reqList[i].readyState == 4 && reqList[i].status == 200) { let resp = reqList[i].responseText; resp = JSON.parse(resp); if (resp.rso.isSuccess == "false") { reqList[i].open("POST", urlList[i], true); reqList[i].send(); } console.log(resp.select_jhkcdm, resp.rso.errorStr); } }; reqList[i].open("POST", urlList[i], true); reqList[i].send(); }

上一篇