查询剩余时间 - 实时获取数据
<p><button onclick='getRemainingTime()'>查询剩余时间</button></p>
<p id='remaining-time'></p>
<script>
function getRemainingTime() {
// 发送AJAX请求
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
// 如果请求成功,更新页面内容
if (xhr.status == 200) {
var remainingTime = parseInt(xhr.responseText);
document.getElementById('remaining-time').innerHTML = '剩余时间:' + remainingTime + '秒';
}
// 如果请求失败,提示用户
else {
alert('请求失败:' + xhr.statusText);
}
}
};
xhr.open('GET', 'time.php', true);
xhr.send();
}
</script>
<p id='remaining-time'></p>
原文地址: https://www.cveoy.top/t/topic/muay 著作权归作者所有。请勿转载和采集!