0

当内容刷新时,我遇到了 PHPinclude和 jQuery的问题,它复制了从onload<li>onloadinclude 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">刷新时,结果都会显示重复。

有人可以帮忙吗?

4

2 回答 2

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>
于 2013-08-31T04:23:50.237 回答
0

您不应该将内容加载到.dropdown-menu而不是 into.ref吗?

于 2013-08-31T04:33:40.040 回答