dtyz76562 2012-09-29 18:41
浏览 43
已采纳

第一次加载后Jquery加载功能卡住了

Hi I have this sample code to load random quotes.

PHP Code:

<?php
  //Selecting Random quotes from database --randomquotes.php
  require('dbconnection.php');
  // $temp=10;
  $sql = "SELECT * FROM db.q order by rand() LIMIT 1";
  $res = mysql_query($sql,$con);
  while ($res1=mysql_fetch_assoc($res))
  { 
    print "<em>".$res1['quote']."</em>";
  }
?>

HTML CODE:

<div class="class_box_shadow_quote">
<?php
  require('randomquotes.php');
?>
</div>

Jquery Code:

<script>
  var $j = jQuery.noConflict();
  $j(document).ready(function(){
    setInterval(function() {
      $j(".class_box_shadow_quote").load('randomquotes.php');
    }, 7000);
  });
</script>

This code is working well for the first time , but is getting stuck on second quote and is not changing the quote. Also everytime i see the second quote to be the same always. What is the problem . Please help?

  • 写回答

2条回答 默认 最新

  • dongren4758 2012-09-29 18:43
    关注

    I believe the output is being cached by jQuery. You can try with caching disabled.

    setInterval(function() {
        $j.ajax({
            url: 'randomquotes.php',
            cache: false,
            success: function(data) {
                $j(".class_box_shadow_quote").html(data);
            }
        });
    }, 7000);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题