I am developing an application where I get the data via JSON and model them via javascript,
I need a help to create an infinite scroll in javascript, showing 10 result and when it arrives at the bottom of the page it loads 10 more, until the data is finished.
What would be the best way to do this?
Below is my code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Xtart</title>
<script src="https://code.jquery.com/jquery-3.2.0.min.js"></script><scripttype="text/javascript">
$(document).ready(function(){
var url="http://xt.art.br/br.art.xt.xtart/API/";
$("#news").html("");
$.getJSON(url,function(data){
$.each(data.members, function(i,user){
var tblRow =
"<div class='posts' style='background-image: url("+user.guid+");'>"
+"<input type='hidden' value='"+user.ID+"'/>"
+"<div class='post_title'><div>"+user.post_title+"</div></div>"
+"</div>";
$(tblRow).appendTo("#news");
});
});
});
</script>
<style type="text/css">
#news{ float: left; width: 100%;}
.posts{float: left; width: 100%; height: 200px; margin-bottom: 10px; background-position: center; background-size: cover;}
.post_title{margin-top:120px; height: 80px; background-image:url(bg_post_title.png); background-repeat: repeat;}
.post_title div{color: #FFFFFF !important; padding: 2px; text-transform: uppercase; text-shadow: 1px 1px #444}
</style>
</head>
<body>
<div id="news"></div>
</body>
</html>