M
M
maxemga2021-04-05 18:58:04
Express.js
maxemga, 2021-04-05 18:58:04

How to load the page only when a request comes from the server?

I have a website and when I update a page or access it, a GET request goes to the server, the server sends a request to the database and the data is shown on the website as cards, but the Pages loaded and only after some time these cards appeared, because you need to wait for the request. The question is how to make the page load only when the request has already arrived, but for now how the page has not loaded, show the loader in the middle of the screen, like many sites?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-04-05
@maxemga

  1. flag variableisLoaded = false
  2. If isLoaded === false- turn the preloader
  3. Sending a request
  4. Request ends
  5. flag variableisLoaded = true
  6. If isLoaded === true- hide preloader and show content

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question