Message from JavaScript discussions

May 2017

— It's not ajax

— 

Form looks like this
<form id="contact" name="contact" method="POST" action="/sandbox/php/contact.php">

— Button like this
<input class="button-primary" type="submit" value="Submit">

— For php, you check $_POST, are you using express with node?

— Im using node, idk about express but I probably will. I haven't touched it yet.

— Express is so amazing, imo

— You can do app.post("/url", callback);

— Then check req.body for the form data

— And that intercepts the form submission with callback ?

— Yes

— Javascript never ceases to impress me

— 

var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.post('/post',function(request,response){
console.log(request.body) //you will get your data in this as object.
})

Message permanent page