从全局增加setInterval()值

时间:2013-09-21 21:26:18

标签: javascript jquery ajax

我试图在setInterval或setTimout上增加超时。但是,我的全球不起作用。我不熟悉javascript。请帮忙!

//What I'm trying to do:

  $(document).ready(function() {
    var joeIncrement=1;
    setInterval(function() {
    joeIncrement++;
    $('#comment_counter').load('get_commentcount.php');
    }, 15000*joeIncrement);
});

1 个答案:

答案 0 :(得分:2)

$(document).ready(function() {
    var joeIncrement=1;
    var interval = function(){
        setTimeout(function() {
            joeIncrement++;
            $('#comment_counter').load('get_commentcount.php');
            interval();
        }, 15000*joeIncrement);
    }
    interval(joeIncrement)
});