jquery 实现滚动条下拉时无限加载的简单实例

var lastId=0; //记录每一次加载时的最后一条记录id,跟您的排序方式有关。
 
   var isloading = false ;
   $(window).bind( "scroll" , function () {
     if ($(document).scrollTop() + $(window).height()
 
        > $(document).height() - 10 && !isloading) {
       isloading = true ;
       getMore();
     }
   });
 
 
 
function getMore() {
     var url = "ajaxdata.aspx" ?lastId= " + lastId +" &type= " + 其他参数
     $.getJSON(url, function (data) {
       var html=" ";
 
        ... ...
 
       $(html).insertAfter($(" .elem").last());
       isloading = false ;
     }
 
   }

猜你喜欢

转载自hoochiang.iteye.com/blog/2359138