Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:33:44+00:00 2026-06-12T00:33:44+00:00

I am developing a website and I want to load the data dynamically on

  • 0

I am developing a website and I want to load the data dynamically on scrolling the page,When the scroll bar reaches the bottom of the page I want to load more data from the database using AJAX.

In my web page there is a iframe in which i want to append the new data.Like flipkart.com website. Where on scrolling the page new products are loaded.

Could anyone help me in this regard?

Thanks in advance.

I have tried many times but no luck what i’m getting is only once the GetActivity() is being called,that too when i scroll down its not calling GetActivity(),but when i scroll up from that point it calls javascript function GetActivity()And on repeating this it is not working
here is the code which i used as given by Greg :please look into this and help.

<html>
<head>
<script type="text/javascript" src="jQuery-1.4.1-min.js"></script>
<script type="text/javascript">
$(window).scroll(function() {
    var bottom = getBottom(window),
        $reset = $("#activity_reset");
    if (bottom == $(this).scrollTop() && $reset.val() == 0) {
        $reset.val(1);
        $("#activity_loading").show();
        if ($("#activity_full").val() == 0) {
            setTimeout("GetActivity();", 100);
        }
    }
});
function getBottom(e) {
    height          = $(document).height();
    windowheight    = $(e).height();
    return height - windowheight;
}
function GetActivity()
{
alert("got it!");
$('div.tt').html('1');
$('div.ttt').html('1');
}
function setting()
{
$('div.tt').html('0');
$('div.ttt').html('0');
}
</script>
</head>
<body onload="return setting()" >
<pre>
<!--here i have used some junk texts so that a scroll bar appears in the browser-->
</pre>
<div style="display:none" id="activity_full" class="ttt"></div>
<div style="display:none" id="activity_reset" class="tt"></div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:33:46+00:00Added an answer on June 12, 2026 at 12:33 am

    This will monitor the page and load the function GetActivity() when you scroll down to the bottom of the page; you can put your ajax call in there and edit this accordingly to display the data you wish to have appear on the page.

    $(window).scroll(function() {
        var bottom = getBottom(window),
            $reset = $("#activity_reset");
    
        if (bottom == $(this).scrollTop() && $reset.val() == 0) {
            $reset.val(1);
            $("#activity_loading").show();
    
            if ($("#activity_full").val() == 0) {
                setTimeout("GetActivity();", 1000);
            }
        }
    });
    
    function getBottom(e) {
        height          = $(document).height();
        windowheight    = $(e).height();
    
        return height - windowheight;
    }
    
    function GetActivity() {
        /* ajax call in here */
    }
    

    When the window is scrolled the .scroll(function()) is triggered; the getBottom(window) function then calculates the document height and the screen height and subtracts them to see if the user’s window has reached the bottom of the screen. $(“#activity_reset”) is then stored to an identifier for later use.

    Once the action is fired your reset value is set to one so that the ajax isn’t fired more than once at a time. The loading bar is displayed and a timeout is then set for the GetActivity() function.

    $(“#activity_reset”) -> Should be a hidden div on the page that holds a value of either 1 or 0; it should be initialized as 0 and when the users browser hits the bottom of the page your ajax call is fired and once it is done being loaded you should then set the value back to 0 to allow loading again.

    $(“#activity_show”) -> Should be a hidden div on the page that contains a loading image, or simply text saying that something is loading (not necessary but certainly helps for user experience).

    $(“#activity_full”) -> Is another hidden div that is used to identify when your div is full and should not load anymore content. It should be initialized to 0 and when you have loaded as many items as can fit on the page you can set it to 1 (likely in your GetActivity() function) to prevent any further loading.

    Further Explaining:
    Inside of your GetActivity() function change the following:

    $('div.tt').html('1');
    //returns <div class="tt">1</div>
    

    to

    $('div.tt').val(1);
    //returns <div class="tt" value="1"></div>
    

    Your code is setting the html of the div to be 1, when what you actually want is for the value attribute to be equal to 1 since that is what the script is checking for in the comparison. I also noticed that you are also setting $(‘div.ttt’) to be 1 as well, but this will stop the script from loading any further. This one should only be set to one once a condition has been met and you would no longer like any items to load.

    $num = 6; //number of items per page
    if($num == 6)
        $('div.ttt').val(1);
    

    Hope that clears things up; let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a website but want a Coming soon page to be up for
I'm developing a website. I want to show all the posts from all users.
I am developing a website and got a database where people can insert data
I am developing a website in which i want to give a search functionality
I'm developing a website with ASP.NET MVC, NHibernate and Fluent NHibernate and want to
I am developing a website for a desktop. Now I want to implement a
I am developing a cooking recipe-website and i want to create a recipe finder
Its related to a website that I am developing, I want to deactivate all
I want to develop an entirely ajax backend for a website I'm developing, and
I am using Django for developing a website and I want to allow my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.