//以下是开发过程中的一个demo函数
window.onload = function () {
getAllRoomInfo();
}
function getAllRoomInfo() {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var info = JSON.parse(this.responseText);
setRoomList(info);
}
}
xmlHttp.open('GET', './RoomServer?type=1', false); //异步改成同步
xmlHttp.send();
}
好吧后来发现根本原因是因为iframe的onload被执行了两次,后端Mysql断开连接时冲突了