2013-09-25 94 views
-1
$(window).scroll(function() { 
    if($(window).scrollTop() == $(document).height() - $(window).height()) { 
     $.ajax({ 
     type: "GET", 
     url: "not_data.php", 
     data: dataString, 
     success: function my_func() { 
      // display 10 new names. 
     } 
     }); 
    } 
}); 

这是not_data.phpAjax请求,同时滚动

<?php 

$name_query=mysql_query("SELECT name FROM names"); 
     while($run_query = mysql_fetch_assoc($name_query)) { 
      $name = $run_query['name']; 

      echo $name; 
} 
?> 

我要调用一个新的Ajax请求,并从表名,每次用户滚动10周新的名字到滚动条的底部。

$名字是从not_dat.php

+0

的可能重复[如何实现在Javascript/jQuery的一个DIV内无限/无限滚动](HTTP: //thinkoverover.com/questions/15181286/how-to-implement-an-endless-infinite-scroll-within-a-div-in-javascript-jquery) – NDM

回答

1

试试这个唯一的变量:

$(window).scroll(function() { 
    if($(window).scrollTop() == $(document).height() - $(window).height()) { 
    $.ajax({ 
    type: "GET", 
    url: "not_data.php", 
    data: dataString, 
    success: function(data) { 
     var htm = null; 
     for(var i=0; i<data.length; i++) { 
      htm += "<div>"+data[i]+"</div>"; 
     } 
     $("container-div-id").append(htm); 
    } 
    }); 
    } 
}); 
+0

谢谢,我会尝试 –

+0

第n个人:/ @Gurminder Singh –

+0

不理解你。 –