Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
How to live update web page while getting content from MySQL using NodeJS (No requests if possible)

I want my website to connect to the database (MySQL) without using requests if possible. If it is necessary to use requests, then how should I implement it, so that only the scripts in the page can make requests to the server and not the user (If he/she gets the link to the API).

Thanks in advance.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Welcome to Stack Overflow. It sounds like you want your web page, displaying in your user's browser, to display data from your MySQL database.

So, you will have three networked programs.

  1. The user's browser displaying your html / css and running your javascript.
  2. Your web server running your nodejs code.
  3. Your MySQL server.

The browser necessarily must initiate requests to the web server. There's no way for the web server to initiate requests to the browser. The web doesn't work that way. Never has. Never will.

The browser cannot interact directly with MySQL. It must go through the web server to do that.

Your web server, upon receiving requests from the browser, looks up what it needs from MySQL, then sends responses back to the browser.

So it's not possible to do what you want without requests.

It is possible to implement a system where the browser sends a request to your web server, and then the web server can send repeated messages to the browser using a data channel set up by that request. It's called WebSockets. A good way to use WebSockets is with socket.io. You can find code for browsers and for nodejs to set this up. It works nicely. Well-known apps like Slack use WebSockets.

But, with respect, you'll have a much easier time coding and debugging socket.io or other WebSocket code if you start with a good understanding of the basics of browser - webserver - MySQL networking. You may wish to do some reading about that first.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda