AJAX refresh script

时间秒杀一切 提交于 2019-12-11 16:49:52

问题


I have some AJAX that refreshes my page but also makes the div that it is refreshing go up and down as it refreshes but i don't wont it to do that, I just wont it to refresh.

How would I edit this code to take out the minimizing and maximizing of the div?

var _v = 0;
var _v2 = 1;


    function ajax_update()
    {
        var wrapperId   =   '#content';
        var postFile    =   'jquery.php';
        _v++;
         _v2++;
        $.post(postFile, { v2: _v2 , v: _v}, function(data){$(wrapperId).slideUp('2000',function(){$(this).html(data).slideDown();}).html();});
        setTimeout('ajax_update()', 2000);

    }

Thanks, Stanni


回答1:


Change this:

$.post(postFile, { v2: _v2 , v: _v}, function(data){
    $(wrapperId).slideUp('2000',function(){
        $(this).html(data).slideDown();
    }).html();
});

To this:

$.post(postFile, { v2: _v2 , v: _v}, function(data) {
    $(wrapperId).html(data);
});

Edited: Will now just replace the contents of the wrapper, there will be no showing/hiding, just refreshing of the contents of $(wrapperId).



来源:https://stackoverflow.com/questions/719191/ajax-refresh-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!