-1

I have a web Application and i wanna to add a function. the function as a table will show inside it some result if the user post a request. and if user not post any thing will show different result when the time left. I work with nodeJs and ejs as view engine. and mongoose as database

1 Answers1

0
  1. I think you want a function to run, if user submits a form. In this case you can use addEventListener method. An example code:
const form  = document.getElementById('myForm');

form.addEventListener('submit', () => {
    /*You can write any code here*/
});
  1. If you want to see a successful post request, (in other words if the visitor has sent data to node.js and if node.js successfully saved this data inside database), then you can set res.status(201) in your node.js file. And then detect 201 from your ejs file and then run your method. You can check this question, if you want a solution with 201: How to get 201 status when uploading a file?
Abdulhakim
  • 620
  • 8
  • 11