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 6781623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:38:45+00:00 2026-05-26T16:38:45+00:00

I know there are plugins to lazy load images. I have a coupon code

  • 0

I know there are plugins to lazy load images. I have a coupon code site, on my category page for shoes in my DB I have 500 coupons that match. I don’t want to display all 500 for obvious reasons. I only want to show 20 initially, and then as the user keeps scrolling down the page it loads more coupons. How would I go about doing this?

EDIT: I’ve got the ajax call working. Here is the code I’m using:

<script type="text/javascript">
        $(window).scroll(function(){
            if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
                $('div#loadmoreajaxloader').show();
                $.ajax({
                    url: "loadmore.php",
                    success: function(html){
                        if(html){
                            $("#postswrapper").append(html);
                            $('div#loadmoreajaxloader').hide();
                        }else{
                            $('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
                        }
                    }
                });
            }
        });
</script>

The problem I have now is how to get the right rows from the database everytime I scroll?

On the initial page load I’m doing this:

SELECT * FROM tblCoupons LIMIT 0,20

What should the mysql call look like in the loadmore.php file? I guess I need to increment a counter somehow….hmmm…

  • 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-05-26T16:38:46+00:00Added an answer on May 26, 2026 at 4:38 pm

    That’s one feature on the internet that I hope goes away… but here’s the deal-

    On page load, you grab like 100 results or however many you want, then spit those into a container. On load, you use jquery to log the height of the content area on your site. Set the starting index so you know what to query for (obviously send the relevant page data in your ajax call), fetch the screen size and wait for scroll. On scroll you check the scrollTop offset plus window size to see if the user is at the bottom of the page within a reasonable threshold – in this case around 100 pixel tolerance. Make the ajax call and then append the results.

    var screen_height = $('body').height();
    var cur-y = $(window).scrollTop();
    var screen = $(window).height();
    var cur_index = 0;
    

    Then apply a scroll listener to body…

    $('body').scroll(function(){
        if($(window).scrollTop() + screen >= (screen_height - 100))
        {
          // make an ajax call to your server and fetch the next 100, then update
          //some vars
            $.ajax({
                url: "your_script.php",
                data: {cur_index:cur_index},
                success: function(){
                    cur_index += 1;
                    screen_height = $('body').height();
    
                   // append content to your container
    
                }
            });
        }
    });
    

    … basically.
    This is not intended to be copy/ paste. but more like a generic guide to how I have done it in the past. You should also set provisions so this only fires once per intended event since .scroll() listens for any scroll movement.

    hope it helps in some way.

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

Sidebar

Related Questions

I know there are tons of plugins/scripts that will pre-load the site while displaying
I know there are many good plugins for pretty alert boxes, but I have
I know there are several plugins that do asynchronous processing. Which one is the
I know there have been a few threads on this before, but I have
First, I know that there are jQuery plugins for search suggest. The reason I'm
I know there are role based authorization gems/plugins for rails to determine if a
I'm looking for a JQuery plugin that supports lazy loading images. The Lazy Load
I know there are basic differences like no plugins and such. But if I
I know there are plugins to export FireBug data , but adding new plugins
I know there are jquery plugins to round the corners on divs but is

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.