掌握球场动态,预测比赛结果。
以下实时更新的表格包含了最新足球比赛的单场比分。数据会不断更新,以便您随时了解比赛的最新情况。
<script>
// 定期从服务器获取实时比分数据setInterval(function() {var xhr = new XMLHttpRequest();xhr.open("GET", "live_scores.php", true);xhr.onload = function() {if (xhr.readyState == 4 && xhr.status == 200) {var data = JSON.parse(xhr.responseText);var tableBody = document.querySelector("tbody");// 清除现有的表行while (tableBody.firstChild) {tableBody.removeChild(tableBody.firstChild);}// 遍历实时比分数据并创建表行for (var i = 0; i < data.length; i++) {var row = document.createElement("tr");var cell1 = document.createElement("td");cell1.textContent = data[i].time;row.appendChild(cell1);var cell2= document.createElement("td");cell2.textContent = data[i].home_team;row.appendChild(cell2);var cell3 = document.createElement("td");cell3.textContent = data[i].score;row.appendChild(cell3);var cell4 = document.createElement("td");cell4.textContent = data[i].away_team;row.appendChild(cell4);tableBody.appendChild(row);}}};xhr.send();}, 1000);
</script>