我正在使用网页作为客户端,并且我正在寻找一种程序来刷新页面的一部分而不刷新整个页面。这部分包括一个日历。 我已经尝试过以下代码:
('#caldiv').fadeOut('slow').load('/Global-Appointment/Scripts/fullcalendar.js.php').fadeIn('slow'); (1000);
('#caldiv').fadeOut('slow').load('/Global-Appointment/Scripts/fullcalendar.js.php').fadeIn('slow'); (1000);
上面的脚本仅每1秒刷新一次日历表,而不会带来任何内容。
我想用数据(内容)实时刷新日历。
答案 0 :(得分:0)
您可以使用纯JS来实现:
<html>
<div id="where-data-will-be-shown"></div>
</html>
[...]
<script>
setInterval(async () => { // Create an interval
const data = JSON.parse(await (await fetch("/where-data-comes-from")).text());
document.getElementById("where-data-will-be-shown").innerHTML = data;
}, 1000)
</script>