I am working on social networking site where i've to load posts as and when user scrolls down. I've written following code to do that :-
$(window).scroll(function(){
var post_count = "<?php echo $Posttotal; ?>";
if($(window).scrollTop() + $(window).height() == $(document).height()){
if(post_count >= 10){
$("#lod_moreimg").show();
loadmoreuserPost();
}
}
});
When i scrolling till the end of the page the load more function is not calling, but if i scroll to the top of the page then the load more function gets called. Can anyone know how to solve this problem? I want to load posts on scroll bottom but in my case the load posts working when i scroll up.