<表id= "table1" class="table1" border="1px"> ;
<tr>
<tr>
<th>資訊</th>
<th>msg</th>
<&th> </tr>
</div>
</div>
js如下:
function Login() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
#############################################################################################H xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");### }###### xmlhttp.onreadystatechange = function() {### if (xmlhttp.readyState == 4 && xmlhttp.status = = 200) { ### var datastr = xmlhttp.responseText;### var dataobj = JSON.parse(datastr)### let dataarr = [];#### for (let i in data let dataarr = [];#### for (let i in dataobj) {##. dataobj[i]);### }###### var table = document.getElementById("table1");### var row = table.insertRow(table.rows.length);##> = row.insertCell(0);### c1.innerHTML = dataarr[0];### var c2 = row.insertCell(1);### c2.innerHTML = dataarr = 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內容進行修改
就這麼思路