$(window).load( function() { bl(); }) function bl() { $('.warp').BlocksIt({ numOfCol: 3, offsetX: 5, offsetY: 5 }); } if($(".gird").length > 0){ var catid = $(".gird").data('id'),next_page = 2,already_rquery = ''; $(window).bind("scroll",function(){ if(next_page != 0 && (already_rquery != next_page)){ if( $(document).scrollTop() + $(window).height() > $(document).height() -1 ){ already_rquery = next_page; $.ajax({ type: "post", url: "index.php?m=Ajax&a=news_list", data: {page:next_page,catid:catid,limit:15}, beforeSend: function(XMLHttpRequest){ $(".loading").show(); }, success: function(data, textStatus){ bl(); //console.log(data) var list = ''; if(data['list'] != null){ $.each(data.list, function(i,item) { list += '

'+data['list'][i].title+'

'+data['list'][i].description+'

> LEARN MORE

'+data['list'][i].createtime+'

'; }); $(".warp").append(list); next_page = data.next_page; bl(); }else{ $(".loading").hide(); } }, complete: function(XMLHttpRequest, textStatus){ $(".loading").hide(); }, error: function(){ }, dataType:"json" }); } } }); }