AJAX 刷新整个 PHP 页面
AJAX refresh whole PHP page
如何更新我页面上的所有 php 数据?我有通信系统,我需要刷新所有 php 数据以更新聊天消息、用户状态等,例如每 750 毫秒。我想 AJAX 可以,但我不知道怎么做。
你可以试试这个,它每 750 秒刷新一次,每 750 毫秒生成一个随机数
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(
function() {
setInterval(function() {
var someval = Math.floor(Math.random() * 100);
$('#sample').text('Test' + someval);
}, 700); //Delay here = 750 milliseconds
});
</script>
</head>
<body>
<div id="sample">Testing refresh every 750 milliseconds</div>
</body>
如何更新我页面上的所有 php 数据?我有通信系统,我需要刷新所有 php 数据以更新聊天消息、用户状态等,例如每 750 毫秒。我想 AJAX 可以,但我不知道怎么做。
你可以试试这个,它每 750 秒刷新一次,每 750 毫秒生成一个随机数
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(
function() {
setInterval(function() {
var someval = Math.floor(Math.random() * 100);
$('#sample').text('Test' + someval);
}, 700); //Delay here = 750 milliseconds
});
</script>
</head>
<body>
<div id="sample">Testing refresh every 750 milliseconds</div>
</body>