How to send data to the request page when using the expressjs Ejs framework?

  node.js, question
router.get('/', function(req, res, next) {
 res.render('demo5.html');  //Rendered Page
 });'/', function(req, res, next) {
 Res.send ("data to be sent");  //Data to Send

After I used ajax post request to send form data in demo5.html, I want to return to the original page data so that ajax can get the data. After executing the penultimate line of the above code, I turn directly to the following figure


How to make the original page unchanged and let ajax get the data, thank you!

I wrote it your way,res.send()It doesn’t make the page jump, if you’re right, your data is informIn, the form submission will cause the page to jump, and then the server the targetres.send()If the results in are returned to the new page, the problem you mentioned will occur. Ajax is the only way to submit data.