如何刷新 DIV 内容?
2022-08-30 12:23:34
<div id='here'></div>
我正在尝试刷新一堆div中的某个div。div内容基本上是由PHP生成的,除了在XMLHttpRequest的帮助下发送的许多变量之外,还有来自MySQL数据库的数据。
这个想法是重新加载/刷新div本身,而不是加载php文件或用或覆盖它。在这种情况下,我不能使用.text
.html
.load('file.php')
我尝试过什么:
<script type='text/javascript'>
function updateDiv()
{
document.getElementById("here").innerHTML = document.getElementById("here").innerHTML ;
}
</script>
和(每3秒刷新一次):
$(document).ready(function () {
setInterval(function () {
$('#here').load('#here'));
}, 3000);
});
理想情况下,我需要这样的东西:
function reloadDIV () {document.getElementById("here").innerHTML.reload}
function reloadDIV () {$('#here').load(self)}
这样我就可以在onClick中使用它:
<a onclick='reloadDIV ();'>reload div</a>