I am using this code for scrolling to get the images but when I am scrolling down multiple images are displayed.
Please can anyone rectify issues, may be problem with if condition.
<script type="text/javascript">
$(document).ready(function(){
$(window).scroll(function(){
var WindowHeight = $(window).height();
//if($(window).scrollTop()+700 >= $(document).height() - WindowHeight)
if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.7){
$("#loader").html("<img src='http://www.niharonline.com/photo/ajax-loader.gif' alt='loading'/>");
var LastDiv = $(".as_country_container:last");
var LastId = $(".as_country_container:last").attr("id");
var ValueToPass = "lastid="+LastId;
$.ajax({
type: "POST",
url: "http://www.niharonline.com/photo/getdata.php",
data: ValueToPass,
cache: true, `enter code here`
success: function(html){
if(html){
LastDiv.after(html);
$('.columns-block').masonry('reload');
}
}
});
return false;
}
return false;
});
});
</script>