Express Js: Implementing Dynamic Data Loading on Scroll

We are currently facing an issue where the dynamic data from Mongo db is loading all at once instead of through scrolling. Our objective is to have the data load progressively as we scroll, all on one single page.

// We attempted using Lazy loading carousel, but unfortunately, it did not work as expected.

function loadStartUp(){         
    $.ajax({
        url: '/createSection',
        type: 'get',
        dataType: 'json',
        success: function (data) {
            var i = 0;
             data.forEach(function(model){
                 console.log(model)

                $('#tbody').append(`
                    <tr>
                        <td>
                            <a href="#" class="tagModalWindow">${model.name}</a>
                        </td>
                           ...
                `)

                navItem(model.name,i); 
                createSection(model.name, model.frequency, i,model.type,model.entity, model,model._id);
                if(model.parameters.length > 0){
                     ...
                }
                i++;
            });

            carousel();
        }
    });


    function carousel(){
        console.log("carousel");
        ...
        });
    }

This section fetches data from the database:

app.get('/createSection', isLoggedIn, (req, res, next)=>{         
    var query = {user:req.user._id};
    dashModel.find(query,(err, data)=>{
        if(err){
            console.log(err)
         } 
        console.log(data)

        res.send(data)
      })
    });

I am relatively new to Express.Js and would appreciate any guidance on how to address this issue. Thank you in advance.

Answer №1

To enhance SEO performance, consider implementing pagination on your website. For client-side implementation, it's beneficial to adopt a pattern that allows search engines like Google to efficiently crawl through your paginated content. You can learn more about this approach at this resource.

When it comes to the back-end handling of data, utilizing Mongoose for database management is recommended. Additionally, incorporating a library like mongoose-paginate can assist in efficient pagination processes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing jQuery for Populating Text Fields and Selecting Checkboxes

Is there a way to take user input and store it in a variable, then insert that information into a webpage like this one? To clarify, I'm looking for a way for an app to transfer data from a variable into an input field on a website (similar to the ex ...

Issue with script execution following Ajax request

I am currently in the process of creating my own portfolio website using Wordpress, and I have decided to write most of the code myself without relying on plugins. One of the key features of my website is a dynamic 'custom post types' grid on the ...

How can I implement draggable and resizable <div> elements to create resizable columns in an antd table using React?

I am currently utilizing the Reacts Antd library to showcase the contents of my table. I am interested in implementing a feature that allows me to resize the column widths. To achieve this, I have wrapped the column in my element as depicted below. The dr ...

What is the best time to fetch the height of an element containing an image?

I am working on my web app and I want to implement a popup element that contains an <img> element. Typically, the image source is larger than necessary, so I resize it using CSS. However, before displaying the popup, I need to determine its outerHeig ...

Seemingly the Tailwind Styles are failing to take effect in my Next.js Project

While following a Next.js tutorial project, I ran into an issue where my project seemed to be way off. It appeared that the tailwind styles were not being applied for some reason, even after tweaking the 'tailwind.config.js' file without success. ...

Enhancing HTML with VueJS and managing imports

After successfully developing a Single Page Application using VueJS, I realized that the SEO performance was not up to par. To combat this, I decided to create a standard HTML website with some pages incorporating VueJS code (since my hosting environment d ...

The form reset function came back as null in the results

I'm attempting to reset the form inputs with the following code: $("#form_employee_job")[0].reset(); Even after executing the code, the inputs remain filled and the console shows undefined What am I overlooking? https://i.sstatic.net/sqzzZ.jpg ...

What are the access permissions needed to add records to a particular database in Mongo DB?

I've been struggling to make my MongoDB container work properly with authentication. After creating a database and a user with the dbAdmin role, I realized that this role doesn't grant enough permissions to insert data into the database. When ru ...

Posting data using an Ajax form submission without the need for page

After numerous attempts, I am still facing an issue where clicking the Submit button causes the page to refresh. What changes should I make to resolve this problem? <script> $('#submit').on('submit', function(event) { event.pre ...

There seems to be a parsing error in the MongoDB database when trying to insert data into a collection

Within my mongodb collection, I have documents in the following format: { "user": "user1", "email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44313721367504213c25293428216a272b29">[email protected]</a>", ...

Trigger a jQuery event when a different selection is made in the dropdown menu

There are 2 choices available in the dropdown menu. <select id="_fid_140" onchange="chooseRecordPicker()" > <option value="736">9000000146</option> <option value="x3recpcker#">&lt; Browse choices... &gt;</option> Upo ...

Sending Parameters Using Higher Order Functions

Utilizing React and attempting to pass multiple arguments along with the 'event', I opted to implement a Higher Order function for this purpose. Unfortunately, it seems that the 'id' passed to the Higher Order function is not being rec ...

Make sure to include the environment variable in the package.json file before running Cypress in headless mode

I am trying to determine whether Cypress is running or not within a NextJS application. My goal is to prevent certain http requests in the NextJS application when Cypress tests are running. Currently, I am able to detect if Cypress is running by using the ...

Tips on setting the appropriate route in Node Express for accessing bower_components?

I am having trouble with correctly defining the path for bower components in my file structure. Here is how it looks: projectName | - client/ | - app/ | - bower_components/ | - node_modules/ (grunt tasks) | - test ...

Vuex data fails to update upon browser reload in Nuxt SSR

After explaining the bug, I discovered something interesting; Component codes async fetch(){ await this.$store.dispatch('bots/getBots') }, computed: { ...mapState('bots', ['bots']) }, Store codes export const state = () ...

Eliminating empty elements from arrays that are nested inside other arrays

I am facing a challenge with the array structure below: const obj = [ { "description": "PCS ", "children": [ null, { "name": "Son", ...

React unable to properly render Array Map method

I am currently working on a project using ChakraUI and React to display a list of team members as cards. However, I am facing an issue where only the text "Team Members" is being displayed on the website, and not the actual mapped array of team members. Ca ...

The issue with depth arises when rotating the camera in threejs

As someone new to the world of threejs, I have created a sample showcasing an issue for better understanding. Feel free to check out the sample here. In this demonstration, you'll notice that dragging the stage horizontally causes the cube and capsu ...

Is it possible to send requests to multiple APIs using a TypeScript event handler?

I'm facing a challenge in pinging multiple APIs within a single function. It seems like it should be possible, especially since each API shares the same headers and observable. I attempted to write a function for this purpose, but unfortunately, it do ...

Sending back numerous information in the catch block

Recently, I was testing out the fetch API and encountered an issue with logging a fetch error. I tried catching the error and logging it within the catch block. Strangely, even when I added additional console.log statements in the catch block, they would ...