1 回答

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊
這是我的問題的解決方案:
async function updateDisplay() {
const response = await fetch ('http://localhost/xxxxx/fetch.php');
const data = await response.text();
const dataObject = JSON.parse(data);
console.log(dataObject);
let li = `<tr><th></th> <td> </td> <th></th></tr>`;
dataObject.forEach(user => {
li += `<tr>
<td>${user.email} </td>
<td>${user.message}</td>
</tr>`;
});
document.getElementById("chat").innerHTML = li;
}
setInterval(updateDisplay, 1000);
- 1 回答
- 0 關(guān)注
- 256 瀏覽
添加回答
舉報(bào)