Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!