无限滚动不适用于chrome

时间:2016-03-05 10:47:09

标签: javascript jquery google-chrome infinite-scroll

下面是无限滚动或自动加载更多内容脚本。此代码在Firefox和Opera中运行良好,但在chrome中不起作用。虽然它显示了初始内容但是当我向下滚动页面时没有任何反应。为什么这不适用于chrome?我怎样才能使它发挥作用?

<script type="text/javascript">
$(document).ready(function() {
 var track_load = 0; 
 var loading  = false; 
 var total_groups = <?=$total_groups;?>;

 $('#results').load("autoload.php", {'group_no':track_load}, function() {track_load++;}); //load first group

 $(window).scroll(function() { 

 if($(window).scrollTop() + $(window).height() == $(document).height()) 
 {

  if(track_load <= total_groups && loading==false) 
  {
    loading = true; //prevent further ajax loading
    $('.animation_image').show(); 

    $.post('autoload.php',{'group_no': track_load}, function(data){

      $("#results").append(data); 

      //hide loading image
      $('.animation_image').hide(); 

      track_load++; 
      loading = false; 

    }).fail(function(xhr, ajaxOptions, thrownError) { 
      alert(thrownError); 
      $('.animation_image').hide(); 
      loading = false;
     });
     }
    }
  });
  });
 </script> 

0 个答案:

没有答案