<表 id= "table1" class="table1" border="1px">
<tr>
<th>信息</th>
<th>msg</th>
<th>认证码</th>
</tr>
</div>
</div>
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp.readyState == 4 && xmlhttp.status = = 200) {
var datastr = xmlhttp.responseText;
var dataobj = JSON.parse(datastr)
let dataarr = [];
for (let i in dataobj) {
dataarr .push(dataobj[i]);
}
var row = table.insertRow(table.rows.length);
var c1 = row.insertCell(0);
c1.innerHTML = dataarr[0];
var c2 = row.insertCell(1);
c2.innerHTML = dataarr[1];
var c3 = row.insertCell(2);
c3.innerHTML = dataarr[2];
}
}
xmlhttp.open("POST", "https://api.123321yun .com/api/user/login?username=test123&password=123456", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp. send();
#}
1。确定要刷新 的元素 比如 id为 #cont
2。ajax不停的请求服务器(后端的逻辑自己写,什么条件下需要更新内容)
3。当请求到新的内容 就将元素#cont内容进行修改
就这么思路