我想用div标签中的PHP代码刷新div,但是它不起作用。控制台说:Uncaught TypeError:$(...)。load不是一个函数在doRefresh
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script></script>
</head>
<body>
<div id="actu">
<?php include 'process.php'; ?>
</div>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
function doRefresh(){
$("#actu").load("process.php");
}
$(function() {
setInterval(doRefresh, 5000);
});
</script>
</script>
</body>
</html>
将您的代码包括在文档就绪处理程序中,以确保脚本在页面加载后便能运行:
<script type="text/javascript">
$( document ).ready(function() {
function doRefresh(){
$("#actu").load("process.php");
}
$(function() {
setInterval(doRefresh, 5000);
});
});
</script>