当include
内容刷新onload
它重复<li>
返回的结果时,我遇到了PHP onload
和jQuery include function
的问题
我的代码如下:
<li class="dropdown">
<a href="#" data-toggle="dropdown" ><img src="style/img/notification.png" /></a>
<ul style="overflow:sauto; width:300px; overflow:auto;" class="dropdown-menu">
<?php include("inc/noti_refresh.php"); ?>
</ul>
</li>
这是我的noti_refresh.php
:
<?php include("configa.php");
$me = $_SESSION['username'];
$noti = mysql_query("select * from notification where to_user = '$me' order by id DESC ");
//$rown = mysql_num_rows($noti);
while ($notime = mysql_fetch_array($noti)){
$me = $notime['to_user'];
$you = $notime['from_user'];
$p_id = $notime['p_id'];
$type = $notime['type'];
$uimage = mysql_query("select * from users where username = '$you'");
$uname = mysql_fetch_assoc($uimage);
$myimage = $uname['img'];
//if( $rown !=0) {
?>
<li class="ref"><a href="photo/<?php echo $p_id; ?>"><img src="users/<?php echo $myimage; ?>" style="height:32px; width:32;" /> <?php echo $you; ?> Has <?php echo $type; ?> Your Image </a></li>
<li class="divider"></li>
<?php }?>
这是我的jQuery函数:
<script type="text/javascript">
function Load_external_content()
{
$('.ref').load('inc/noti_refresh.php').hide().fadeIn(3000);
}
setInterval('Load_external_content()', 10000);
</script>
现在每当刷新<li class="ref">
时,结果都会显示重复。
有人可以帮忙吗?
答案 0 :(得分:0)
我通过删除<?php include('notif_refresh.php');
解决了这个问题
而我只是使用了这两个函数
<script type="text/javascript">
$(document).ready(function(){
$('.ref').load('inc/noti_refresh.php');
});
</script>
<script type="text/javascript">
function Load_external_content()
{
$('.ref').load('inc/noti_refresh.php').hide().fadeIn(3000);
}
setInterval('Load_external_content()', 10000);
</script>
答案 1 :(得分:0)
您是否应该将内容加载到.dropdown-menu
而不是加载到.ref
?