My infinite scroll code is causing a problem - it only works when scrolling up, not down. Can someone help me fix this issue?
<script type="text/javascript">
$(document).ready(function(){
$(window).scroll(function(){
var lastID = $('.load-more').attr('lastID');
if(($(window).scrollTop() == $(document).height() - $(window).height()) && (lastID != 0)){
//Why work when scroll up? i want this work when scroll down
$.ajax({
type:'POST',
url:'<?php echo base_url('berita/load_more'); ?>',
data:'id='+lastID,
beforeSend:function(){
$('.load-more').show();
},
success:function(html){
$('.load-more').remove();
$('#postList').append(html);
}
});
}
});
});
</script>
Check out the live demo at