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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:03:49+00:00 2026-06-04T04:03:49+00:00

I am using the following code which is working when the scroll bar reaches

  • 0

I am using the following code which is working when the scroll bar reaches the botttom,

if($(window).scrollTop() == $(document).height() - $(window).height()){

I however want that the ajax is fired when i reached 70% of the scroll not 100.

  • 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-04T04:03:50+00:00Added an answer on June 4, 2026 at 4:03 am

    Provided your current check is firing when scrolled to the page’s bottom, you can try some basic arithmetics:

    if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.7){
                                              //where 0.7 corresponds to 70% --^
    

    Make sure to add a check to don’t fire multiple simultaneous Ajax requests, if you didn’t already.

    This is rather out of the scope of the question, but if you want an example of how to prevent multiple requests from being fired simultaneously:

    Declare a global var, e.g. processing.

    Then incorporate it in your function:

    if (processing)
        return false;
    
    if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.7){
        processing = true; //sets a processing AJAX request flag
        $.post("url", '<params>', function(data){ //or $.ajax, $.get, $.load etc.
            //load the content to your div
            processing = false; //resets the ajax flag once the callback concludes
        });
    }
    

    That’s a simple example of using a var to keep track if there is an active Ajax request for your scroll function or not, and it doesn’t interfere with any other concurring Ajax request which you may have.

    Edit: JSFiddle example

    Please note that using a % to measure the document height might be a bad idea, considering that the document’s height will increase each time you load something, making it trigger the Ajax request being relatively more far from the bottom of the page (absolute-size wise).

    I’d recommend using a fixed value offset to prevent that (200-700 or so):

    if ($(window).scrollTop() >= $(document).height() - $(window).height() - 700){
                                     // pixels offset from screen bottom   --^
    

    Example: JSFiddle

    Edit: To reproduce the issue in the first code with percentages, load 50 divs into it. When you load the next div, it’ll add only 2% to the total document’s height, meaning the next request will be triggered as soon as you scroll these 2% back to the 70% of the document’s height. In my fixed example, the defined bottom offset will load new content only when the user is at a defined absolute pixels range from the bottom of the screen.

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

Sidebar

Related Questions

I have a javascript code using which I want to accomplish the following .
To scroll down my chat DIV I am using the following code which is
I have the following code in child window which is working but what I
I have the following code which is working great for me. I am using
I'm using the following code which will generate a wav file which contains a
I'm using he following code the call a CFC which returns auto-suggest results through
I'm using the following code to post to the server which is then sent
Given the following lines of code which is using JQTOUCH: $('#customers').bind('pageAnimationEnd', function(e, info){ if
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I am using ups service for my project,I have the following code which 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.