jQuery ajaxStart,ajaxStop尴尬行为

|| 我这样做是为了说明我的问题: http://jsfiddle.net/michaelhart/mUMHZ/ (仅在Chrome中测试。) 总结:我不希望当用户转而返回时,ajax活动指示器会发疯。 我试过了
$(\"#notification\").clearQueue();
$(\"#notification\").hide();

$(\"#notification\").clearQueue();
$(\"#notification\").show();
之前
$(\'#notification\').fadeOut();
但这只会导致跳出标签后指示器完全停止运行。 我不确定这是Google Chrome处理非活动标签页的方式中的错误还是Chrome将其置于“休眠”状态时jQuery工作方式中的错误。 有任何想法吗?     
已邀请:
        该错误已在jQuery错误跟踪器中记录。建议的解决方法是,不要盲目地使用setInterval,而是使用动画的回调函数以setTimeout触发重新启动。 例如。
$(document).ready(function() {
    fetchAjax();
});

function fetchAjax() {
        var randomnumber=Math.floor(Math.random()*10001);
        $(\'#number\').html(randomnumber);
        $.ajax({
            type: \'POST\',
            url: \'/echo/html/\',
            data: {
              \'html\': randomnumber
            },
            dataType: \'text/html\'
        });
}

$(document).ajaxStart(function(){
    $(\'#notification\').fadeIn();
}).ajaxStop(function(){
    $(\'#notification\').fadeOut(function(){
      setTimeout(function(){ fetchAjax(); }, 5*1000);
    });
});
    

要回复问题请先登录注册