Wednesday, 12 April 2017

event.preventDefault affecting response.render in Node

I have a form in my html view, <form action="/" method="POST" id="compareForm">and when I submit that form, my node controller would handle it and render a new view called results.

router.post('/', function(req, res) /*code*/ {res.render('results', {}}

I decided i wanted to customize the submit behavior so I did some jquery and by the looks of it, my submission makes it into router.post, but res.render does not seem to work. I took the example from https://api.jquery.com/submit/ to customize my submit but, I suspect event.preventDefault is causing the issue. If I comment it out I can do res.render...but it calls router.post twice, which is wrong.



via Michael

No comments:

Post a Comment