Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda