0
Personal talk... I’m developing an application where I get the data via JSON and template them via javascript, so far so good...
I need a help to create an Infinite scroll in javascript, showing 10 result and when arriving 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 follows 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>
<script type="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>
Thanks @Lucasmarques helped me a lot!
– Lucas Linhares