Express 如何将res发送回我的目录中的本地html文件
此代码来自我目录中的本地html文件, 如何发送回html文件res.send(“确定”)Express 如何将res发送回我的目录中的本地html文件,express,Express,此代码来自我目录中的本地html文件, 如何发送回html文件res.send(“确定”) 尝试简单地将res.send(“ok”)移动到if检查错误的外部,因为现在只有在出现错误时它才会发送响应: app.post('/', (req, res) => { let data = { name: req.body.name, email: req.body.email, pass: req.body.pass, contact: req.body.cc
尝试简单地将
res.send(“ok”)
移动到if
检查错误的外部,因为现在只有在出现错误时它才会发送响应:
app.post('/', (req, res) => {
let data = {
name: req.body.name,
email: req.body.email,
pass: req.body.pass,
contact: req.body.ccontact
}
const action = req.body.action;
if (action == "submit") {
req.checkBody("name", "Enter a valid name address.").notEmpty()
req.checkBody("email", "Enter a valid email address.").isEmail()
req.checkBody("pass", "Enter valid password address.").isAlphanumeric()
req.checkBody("contact", "Enter valid address.").notEmpty().isNumeric()
let error = req.validationErrors()
if (error) {
console.log(error)
}
res.send("ok");
亲爱的谢谢你的快速回复,但我想把这个res发送到我的目录中的其他html文件。从html文件im通过ajax发送数据。
app.post('/', (req, res) => {
let data = {
name: req.body.name,
email: req.body.email,
pass: req.body.pass,
contact: req.body.ccontact
}
const action = req.body.action;
if (action == "submit") {
req.checkBody("name", "Enter a valid name address.").notEmpty()
req.checkBody("email", "Enter a valid email address.").isEmail()
req.checkBody("pass", "Enter valid password address.").isAlphanumeric()
req.checkBody("contact", "Enter valid address.").notEmpty().isNumeric()
let error = req.validationErrors()
if (error) {
console.log(error)
}
res.send("ok");