weixin_33674976 2014-12-10 07:16 采纳率: 0%
浏览 34

jQuery Ajax定期加载

i want to load the changes done to a particular document dynamically. the storysource.php would be given database connectivity and all. but presently only a echo statement is given for testing. the ajax works fine and data is getting loaded. but it is not reloading itself and changing the data as it changes.

<script>
function keertan()
{

    $.ajax({
    url: "storysource.php",
      success: function(result) {
      $('.centre').append('<div style="background-color:red;">'+result+'</div>');
        },
    complete:function(){
        setInterval('keertan',1000);
        }
        });

    }

            keertan();
    </script>
  • 写回答

2条回答 默认 最新

  • 七度&光 2014-12-10 07:24
    关注

    you can call a function like this :

        <script>
            function keertan()
            {
                $.ajax({
                url: "storysource.php",
                success: function(result) {
                    $('.centre').append('<div style="background-color:red;">'+result+'</div>');
                },
            }
    
            keertan();
    
            setInterval(function(){
                keertan();
            },1000);
    
       </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?