【发布时间】:2019-05-01 21:19:15
【问题描述】:
我正在扩展 Node.js 并将它们与 HTML 文件一起使用。
但是,我无法弄清楚以下内容。
我构建了一个form.html,其中可以收集firstName、lastName 等变量。填充了form,按下了底部,执行了一个带有action = "/signup"的app.js。
action 后跟以下 app.js,其中包含:
// Bodyparser Middleware
app.use(bodyParser.urlencoded({ extended: true }));
// Static folder
app.use(express.static(path.join(__dirname, 'public')));
//signup route
app.post('/signup', (req, res){
//Processes including storing data into mailchimp and mongodb
});
现在执行该过程后,将打开一个新的 HTML 文件,success.html。
在success.html 中,我希望创建一个自定义消息,其中包含从form.html 的先前进程中收集的一些变量。
<p>Sample text <h1><%= name %></h1> sample text</p>
我已经尝试过建议here 和here 和其他选项的解决方案。我什至尝试更改为action = "file.php",然后使用不同的<form action=""> 执行两个.php 文件,但它不起作用。
【问题讨论】: