Basit Basit - 1 year ago 135
Javascript Question

jQuery load more data on scroll

im just wondering how can i implement more data on scroll only if the div.loading is visible.

usually we look for page height and scroll height, to see if we need to load more data. but the following example is little complicated then that.

following image is perfect example. there are two .loading div's on the drop down box. when user scroll the content, whichever is visible it should start loading more data for it.

enter image description here

so how can i find out if .loading div is visible to user yet or not? so i can start loading data for that div only.

Answer Source

Have you heard about the jQuery Waypoint plugin.

Below is the simple way of calling a waypoints plugin and having the page load more Content once you reaches the bottom on scroll :

$(document).ready(function() {
    var $loading = $("<div class='loading'><p>Loading more items&hellip;</p></div>"),
    $footer = $('footer'),
    opts = {
        offset: '100%'

    $footer.waypoint(function(event, direction) {
        $.get($('.more a').attr('href'), function(data) {
            var $data = $(data);
    }, opts);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download