我正在处理HTML表单,将数据处理到服务器(使用express和nodejs)并返回到客户端。以下是我的程序。
//My folder structure
-index.js
-public
-index.html
-timer.html
-...
<form method="POST" action="/timer">
<input type="text" name="name">
<button type="submit">Submit</button>
</form>
app.post('/timer', urlencodedParser, (req,res) => {
const data = req.body;
res.sendFile('public/timer.html' , { root : __dirname, data: req.body});
})
非常感谢!