-1

I am returning a simple response in node.js with res.send() in response to a POST request. My problem is that I want the client to stay on the same page. Currently the client just gets taken to a blank page that has the contents of res.send() written on it. But I want the client to update it's current page (the page from which the POST request was sent) instead of displaying the response. Is there a way to do this?

Sam
  • 129
  • 2
  • 11
  • 1
    How is the client making the POST request? – Davin Tryon Jun 23 '15 at 16:16
  • Yes, you can redirect the user to whichever page you want using the answer here http://stackoverflow.com/questions/25895292/node-js-redirection-after-submiting-a-form. Another thing to consider is doing it client-side by submitting the form yourself and preventing the default behavior http://stackoverflow.com/questions/6462143/prevent-default-on-form-submit-jquery – bbill Jun 23 '15 at 16:25
  • The POST is being done through a html form. I don't want it to redirect to any other page. For example, I would like to have a certain div show up upon receiving a certain response message. – Sam Jun 23 '15 at 17:32

1 Answers1

1

You need to change the action of your HTML form using jquery, angular, or backbone (etc..) The page change is the default functionality of a html form submission, and this cannot be resolved by node.js.

Hyo Byun
  • 1,196
  • 9
  • 18