Sibeesh Passion

Top Menu

  • Home
  • Search
  • About
  • Privacy Policy

Main Menu

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Home
  • Search
  • About
  • Privacy Policy

logo

Sibeesh Passion

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment

  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins

  • Post Messages to Microsoft Teams Using Python

  • Get Azure Blob Storage Blob Metadata Using PowerShell

  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines

CodeProjectJQuery
Home›CodeProject›Load Data on Scroll Using jQuery

Load Data on Scroll Using jQuery

By SibeeshVenu
June 30, 2015
1571
0
Share:

Introduction

Hi all, how are you today? This article explains how to load data on demand or load data when the user scrolls. Here we will do this in a simple manner, I hope you enjoy it.

Download Source Code

  • LoadDataOnScroll
  • Background

    A few days ago one of my colleagues asked me how to load data into the UL when we do scroll. I could help him on that time itself. But here I am writing this article for his future reference. In this way we can do this very easily.

    Using the code

    Since we will load the data on a scroll, we need to fire the window events. So I suggest include a jQuery plugin in your page as in the following:
    [js]
    <script src=“jquery-2.1.4.min.js”></script>
    [/js]

    Once you are done, you are ready to go!

    Our next step is load some initial or static data.
    [html]
    <div id=“myScroll”>
    <p>
    Contents will load here!!!.<br />
    </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    </div>
    [/html]

    Now we need some styles, right?

    [css]
    <style>
    #myScroll {
    border: 1px solid #999;
    }
    p {
    border: 1px solid #ccc;
    padding: 5px;
    text-align: center;
    }
    .loading {
    color: red;
    }
    .dynamic {
    background-color:#ccc;
    color:#000;
    }
    </style>
    [/css]

    What is next? Shall we run it and see our page now?

    So now we have loaded the static data. Now it is time to fire the scroll event.
    [js]
    $(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() – $(window).height()) {
    appendData();
    }
    });
    [/js]

    In the preceding code, I am calling the scroll event and when the condition $(window).scrollTop() == $(document).height() – $(window).height() is satisfied, I am calling a function. You can see the function below.
    [js]
    function appendData() {
    var html = ”;
    for (i = 0; i < 10; i++) {
    html += ‘<p class=”dynamic”>Dynamic Data : Life treats you in the same way, how you treat your life.Follow your passion, be prepared, do not let anyone limit your dreams. My Passion towards my life !!! – See more at:<a href=”http://sibeeshpassion.com/”>http://sibeeshpassion.com/</a> </p>’;
    }
    $(‘#myScroll’).append(html);
    }
    [/js]

    Here I am populating 10 records dynamically and appending the created data to our main element. Once you are done, you can see the output as in the following.

    Complete Code
    [html]
    <!DOCTYPE html>
    <html>
    <head>
    <title>Load data on demand demo – Sibeesh Passion</title>
    <script src=“jquery-2.1.4.min.js”></script>
    <style>
    #myScroll {
    border: 1px solid #999;
    }
    p {
    border: 1px solid #ccc;
    padding: 5px;
    text-align: center;
    }
    .loading {
    color: red;
    }
    .dynamic {
    background-color:#ccc;
    color:#000;
    }
    </style>
    <script>
    $(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() – $(window).height()) {
    appendData();
    }
    });
    function appendData() {
    var html = ”;
    for (i = 0; i < 10; i++) {
    html += ‘<p class=”dynamic”>Dynamic Data : Life treats you in the same way, how you treat your life.Follow your passion, be prepared, do not let anyone limit your dreams. My Passion towards my life !!! – See more at:<a href=”http://sibeeshpassion.com/”>http://sibeeshpassion.com/</a> </p>’;
    }
    $(‘#myScroll’).append(html);
    }
    </script>
    </head>
    <body>
    <div id=“myScroll”>
    <p>
    Contents will load here!!!.<br />
    </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    <p >Life treats you in the same way, how you treat your life.Follow your passion, be prepared, don’t let anyone limit your dreams. My Passion towards my life !!! – See more at: http://sibeeshpassion.com/ </p>
    </div>
    </body>
    </html>
    [/html]

    Conclusion

    Please download the source code for more details. I hope you liked this article. Now please share your thoughts and suggestions. It matters a lot.

    Kindest Regards
    Sibeesh Venu

    TagsJQueryjquery eventsjQuery onScroll Data LoadingLoad Data jQueryonscroll
    Previous Article

    Filter parameters are always null in server ...

    Next Article

    Check whether an array contains a particular ...

    0
    Shares
    • 0
    • +
    • 0
    • 0
    • 0

    SibeeshVenu

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer.

    Related articles More from author

    • Custom Pager Using prev and next In jQuery
      JQuery

      Custom Pager Using prev and next In jQuery

      October 21, 2015
      By SibeeshVenu
    • Code SnippetsJQuery

      How to remove the spaces between the string in JQuery

      May 31, 2015
      By SibeeshVenu
    • Important CSS Property In JQuery And CSS
      CodeProjectCSSCSS3JQuery

      Apply CSS Important In JQuery And CSS

      September 29, 2015
      By SibeeshVenu
    • Create Custom Colour Palette
      HTML5JQuery

      Creating Custom Color Palette Using JQuery, HTML5, CSS

      March 29, 2015
      By SibeeshVenu
    • Code SnippetsJQuery

      Read appsetting from a web config file in client side

      May 31, 2015
      By SibeeshVenu
    • Code SnippetsJQuery

      How to use css property in JQuery

      May 31, 2015
      By SibeeshVenu
    0

    My book

    Asp Net Core and Azure with Raspberry Pi Sibeesh Venu

    YouTube

    MICROSOFT MVP (2016-2022)

    profile for Sibeesh Venu - Microsoft MVP

    Recent Posts

    • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment
    • Build, Deploy, Configure CI &CD Your Static Website in 5 mins
    • Easily move data from one COSMOS DB to another
    • .NET 8 New and Efficient Way to Check IP is in Given IP Range
    • Async Client IP safelist for Dot NET
    • Post Messages to Microsoft Teams Using Python
    • Get Azure Blob Storage Blob Metadata Using PowerShell
    • Deploy .net 6 App to Azure from Azure DevOps using Pipelines
    • Integrate Azure App Insights in 1 Minute to .Net6 Application
    • Azure DevOps Service Connection with Multiple Azure Resource Group

    Tags

    Achievements (35) Angular (14) Angular 5 (7) Angular JS (15) article (10) Article Of The Day (13) Asp.Net (14) Azure (65) Azure DevOps (10) Azure Function (10) Azure IoT (7) C# (17) c-sharp corner (13) Career Advice (11) chart (11) CSharp (7) CSS (7) CSS3 (6) HighChart (10) How To (9) HTML5 (10) HTML5 Chart (11) Interview (6) IoT (11) Javascript (10) JQuery (82) jquery functions (9) JQWidgets (15) JQX Grid (17) Json (7) Microsoft (8) MVC (20) MVP (9) MXChip (7) News (18) Office 365 (7) Products (10) SQL (20) SQL Server (15) Visual Studio (10) Visual Studio 2017 (7) VS2017 (7) Web API (12) Windows 10 (7) Wordpress (9)
    • .NET
    • Achievements
    • ADO.NET
    • Android
    • Angular
    • Arduino
    • Article Of The Day
    • ASP.NET
    • Asp.Net Core
    • Automobile
    • Awards
    • Azure
    • Azure CDN
    • azure devops
    • Blockchain
    • Blog
    • Browser
    • C-Sharp Corner
    • C#
    • Career Advice
    • Code Snippets
    • CodeProject
    • Cognitive Services
    • Cosmos DB
    • CSS
    • CSS3
    • Data Factory
    • Database
    • Docker
    • Drawings
    • Drill Down Chart
    • English
    • Excel Programming
    • Exporting
    • Facebook
    • Fun
    • Gadgets
    • GitHub
    • GoPro
    • High Map
    • HighChart
    • How to
    • HTML
    • HTML5
    • Ignite UI
    • IIS
    • Interview
    • IoT
    • JavaScript
    • JQuery
    • jQuery UI
    • JQWidgets
    • JQX Grid
    • Json
    • Knockout JS
    • Linux
    • Machine Learning
    • Malayalam
    • Malayalam Poems
    • MDX Query
    • Microsoft
    • Microsoft ADOMD
    • Microsoft MVP
    • Microsoft Office
    • Microsoft Technologies
    • Microsoft Windows
    • Microsoft Windows Server
    • Mobile
    • MongoDB
    • Monthly Winners
    • MVC
    • MVC Grid
    • MySQL
    • News
    • Node JS
    • npm
    • Number Conversions
    • October 2015
    • Office 365
    • Office Development
    • One Plus
    • Outlook
    • Page
    • PHP
    • Poems
    • PowerShell
    • Products
    • Q&A
    • Raspberry PI
    • React
    • SEO
    • SharePoint
    • Skype
    • Social Media
    • Software
    • Spire.Doc
    • Spire.PDF
    • Spire.XLS
    • SQL
    • SQL Server
    • SSAS
    • SSMS
    • Storage In HTML5
    • Stories
    • Third Party Software Apps
    • Tips
    • Tools
    • Translator Text
    • Uncategorized
    • Unit Testing
    • UWP
    • VB.Net
    • Videos
    • Virtual Machine
    • Visual Studio
    • Visual Studio 2017
    • Wamp Server
    • Web API
    • Web Platform Installer
    • Webinars
    • WebMatrix
    • Windows 10
    • Windows 7
    • Windows 8.1
    • Wordpress
    • Writing

    ABOUT ME

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer. If you would like to know more about me, you can read my story here.

    Contact Me

    • info@sibeeshpassion.com

    Pages

    • About
    • Search
    • Privacy Policy
    • About
    • Search
    • Privacy Policy
    © Copyright Sibeesh Passion 2014-2025. All Rights Reserved.
    Go to mobile version