【问题标题】:Live Reload refresh after 6s, and sometimes plantedLive Reload 6s 后刷新,有时被种植
【发布时间】:2013-08-06 06:37:45
【问题描述】:

你知道是否有解决 livereload 功能的方法吗?因为一个星期,它不再起作用,或者几乎:(

刷新发生在6s之后,很长,太长了。之前,我有一个关于 js 文件的错误消息,这很奇怪。

您有解决方案或替代 livereload 的方法吗?

谢谢你:)

【问题讨论】:

    标签: javascript html css livereload


    【解决方案1】:
    setInterval(yourFunction, timeout) 
    

    以毫秒为单位的超时

    【讨论】:

    • 大家好,我对毫秒有疑问,是分钟吗?
    【解决方案2】:

    是的,有一个解决方案。阿贾克斯。

    已编辑

    http://api.jquery.com/jQuery.ajax/

    这将每 6 秒运行一次代码。只需将此代码存储到文档头部即可。

    var timer = null;
    function loader(){
        if (timer) {
            clearTimeout(timer);
            timer = null;
            return;
        }
        timer = window.setInterval(function(){
          // DO SOME CODE
        }, 6000);
    }
    
    window.onload = function() {
        loader();
    };
    

    演示:http://jsfiddle.net/FK452/1/

    这会将页面boo.php 加载到<div id="content"> </div>。您可以通过 $_POST 访问 var jsonboo.php -> $_POST['json'], $_POST['second']:

    $.post('boo.php', {json: "value", second: "val"}, function(html){
      $("#content").html(html);
    });
    

    【讨论】:

      猜你喜欢
      • 2013-04-20
      • 1970-01-01
      • 2022-01-19
      • 2020-01-02
      • 2013-05-09
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 2018-08-24
      相关资源
      最近更新 更多