Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

Ajax刷新出现闪烁情况

代码:

update.js代码

var skip_updates = false;
function init_updater() {
    function update() {
        if (skip_updates) return;
        $.ajax({
            url: location.href,
            cache: false,
            dataType: "html",
            success: function(resp){
                $("#wrapper").find(".main-content").html(resp);
            }
        });
    }
    setInterval(update, 10000);
}

效果:

图片描述

理想的状态:

应该是无闪烁的刷新的
web布局:

<body>
    <div id="wrapper">
        <div class="main-content">
            ...其他代码
        </div>
    </div>
</body>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

亲,这个由于盒子的宽度导致的,建议加个过渡动画,另外加载完html后,不要立即显示,加入淡入的效果显示会更佳!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...