2012-05-13 28 views
2

那麼我做了一個無限的滾動腳本,表現相當好。但只是在Chrome和IE中。不幸的是,它不會在Firefox上執行同步調用,但仍然會導致服務器異步...意義我收到了大量不應該被請求的內容...因爲我在Google上搜索並沒有找到明確的解決方案對於我的問題,所以我會問你們:JQuery SYNC在Firefox中的Ajax調用錯誤

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; 
       }       
      }, 
     }); 
    } 
} 
}); 

回答

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'); 
      } 
+0

都能跟得上不改變unfortunaly的事情......但我給它的一個念頭,可能會嘗試解決這個問題serversided因爲我用PHP是更好的xD反正.. 。 –

+1

@IvanSchrecklich - 抱歉,這沒有用。祝你好運服務器端! :) –