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

110
Views
Open connection to MongoDB when page is loaded

new web developer here,

I am creating a test website where I can input data and add it to my MongoDB database. I have a JavaScript file that manages the connection with my MongoDB database (app.js), and I have another JavaScript file that manages the elements within my webpage. (script.js)

I am trying to make it so when I load the page where I input data, I can call the method which connects the database, and I can use that allows me to push form data to my MongoDB database.

The only thing I am struggling with is how I would detect that the webpage is loaded and run the method that opens my database.

I am also struggling to understand how to pass my 'db' variable into my script.js file to allow me to get data from my webpage.

Any help is appreciated, I am using WebStorm to create my website.

EDIT: And links to resources that solve a similar issue to mine (basically sending data to MongoDB from a webpage), would be very helpful! I think I am also using nodejs for my app.js file

about 4 years ago · Juan Pablo Isaza
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!