Tuesday 15 June 2010

node.js - node, express, jade: How to process form data -


Is there any best practice code pattern that can process HTML form data with Express and Z templates? I was wondering if this form template means to use PHP like the self-calling loop, then tell in your router script that you have two handlers for the same route, one for GET and another post request Something like this:

  export.getHandler = function (rick, ridge) {res.render ('/ formhandling /', {mode: "form-filling"}); } Export.postHandler = function (req, res) {res.render ('/ formhandling /', {mode: "form-processing"}); }   

and may look like a z template

  Layout increases the block content h1 # {title} if mode == "form-processing" p Form data processed ... and form (name = "", method = "post", verb = "/ form-handling /") ...   

Does this make sense Is or is it something wrong to get me something?

I think you just use jQuery to hide the form after the user has been submitted. If you want to make any processing of the form on the server side, then you can do that in your app. Js

  app.get ('/', routes.form); APPOST ('/', function (race, rake)) / / Form processing here can also be done with an external route * /});   

Edit: Also,

No comments:

Post a Comment