I am working on a website that automatically downloads new content from a MySQL database in a scroll. But the problem is that it loads new content, even if the scroll is negligible. I mean, it loads the new content into the scroll, but not at the end of the page. The scrollable section is in a static frame.
JQuery Code:
<script type="text/javascript">
$(document).ready(function() {
var track_load = 0;
var loading = false;
var total_groups = <?php echo $total_groups; ?>;
$('#results').load("autoload_process.php", {'group_no':track_load}, function() {track_load++;});
$("#frames").scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height())
{
if(track_load <= total_groups && loading==false)
{
loading = true;
$('.animation_image').show();
$.post('autoload_process.php',{'group_no': track_load}, function(data){
$("#results").append(data);
$('.animation_image').hide();
track_load++;
loading = false;
}).fail(function(xhr, ajaxOptions, thrownError) {
alert(thrownError);
$('.animation_image').hide();
loading = false;
});
}
}
});
});
</script>
Guys, please help me with this. Maybe there is some problem with `
$ (window) .scrollTop () + $ (window) .height () == $ (document) .height () `this part.
I want to track the scroll of a section, not a window.
source
share