【发布时间】:2014-08-26 23:39:18
【问题描述】:
我正在编写一个消息传递 PHP 脚本。为了查看用户他们的消息,我正在尝试重新加载 DIV,以便我应该是实时的。我有两个页面,第一页是显示新消息数量的地方:
<?php
include ('config.php')
?>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script>
var auto_refresh = setInterval(function () {
$('#xxxx').fadeOut('slow', function() {
$(this).load('message.php', function() {
$(this).fadeIn('slow');
});
});
}, 40000);
</script>
<div id="xxxx"><?php include ('yahu.php') ?></div>
其他页面显示重新加载结果:
<?php
include ('config.php');
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
if ($nb_new_pm == 0)
{
}
else
{
?>
<font color="black">You have got <?php echo $nb_new_pm; ?> new message(s).</font>
<?php
}
?>
首先,它工作得非常好。但是当页面重新加载时,它只显示
的值
“nb_new_pm”,它也将其颜色更改为白色。
请帮帮我!!!!!!
【问题讨论】:
-
欢迎来到 StackOverflow!您是否尝试检查现有的消息传递系统?谷歌它并从现有的学习。尽量不要重新发明轮子……
标签: javascript php jquery html reload