2

さて、私は非常にうまく機能している無限スクロール スクリプトを作成しました。しかし、ChromeとIEだけです。残念ながら、Firefoxで同期呼び出しを実行しませんが、サーバーを非同期にします...つまり、要求されるべきではない大量のコンテンツが返されます...グーグルで調べていて、明確な解決策が見つかりませんでした私の問題については、皆さんにお尋ねします:

var endajax = 0;

$(window).scroll(function(){
    if (endajax == 0)
    {
        if($(window).scrollTop() + $(window).height() > $(document).height() - 405) 
    {
            $('#profilecontent').prepend('<div class="iloader bgtrans padding ui-corner-all" style="position: fixed; bottom: 20px; right: 80px;"><div class="ui-widget-content ui-corner-all padding"><img width="8" src="images/loader.gif" alt="" /> Inhalt wird nachgeladen, bitte einen Moment gedulden</div></div>');
        var firstid = $('.postbox').last().attr('name');    
        var lastid = $('.postid').last().val(); 
        var data = "firstid="+firstid+"&lastid="+lastid+"&uid=<?php echo $profileuser->id; ?>"; 
        setTimeout(function() {
            $('.iloader').remove();
        }, 2000);
        $.ajax({
        url: "modules/users/profile/profileposts.php",
        cache: false,
        type: "POST",
        async: false,
        data: data,
            success: function(data){
                if (data.length != 2) {
                      $('#profileposts').append(data).fadeIn('slow');
                }
                else
                {
                    endajax = 1;
                }                           
            },
        });
    }
}
});
4

1 に答える 1

0

おそらく、ajax 呼び出しの前にセマフォをロックしますか?

if($(window).scrollTop() + $(window).height() > $(document).height() - 405) 
{
 endajax++;

その後

success: function(data){
            if (data.length != 2) {
                  endajax = 0;//or 1 depending on how you are locking this control out
                  $('#profileposts').append(data).fadeIn('slow');
            }
于 2012-05-13T22:05:30.770 に答える