在Node.js中渲染到新网页之前的警报消息

时间:2018-08-15 15:39:25

标签: javascript node.js express handlebars.js

我是NODEJS的初学者。我试图在呈现到新页面之前在浏览器上显示警报消息。我无法这样做。你能指导我吗?

hbs文件

<form id="form1" action="/emp_details" method="post">
    <label for="NAME_FIELD">NAME</label>
    <input id="NAME_FIELD" type="text" name="NAME_FIELD" autocomplete="off">
    <br><br>

    <label for="EMAIL_FIELD">EMAIL</label>
    <input id="EMAIL_FIELD" type="text" name="EMAIL_FIELD" autocomplete="off">
    <br><br>

    <label for="GENDER">GENDER</label>
    <select
    id="GENDER" name="GENDER">
    <option value="male">MALE</option>
    <option value="female">FEMALE</option>
    <option value="others">OTHERS</option>

    </select><br><input type="submit" value="submit">
</form>

js文件

app.get('/', (req, res) => {
    res.render('home');
})

app.post('/emp_details', function (req, res) {
    console.log(req.body);
    //SOMETHING HERE TO ALERT
    res.render('/emp_details')
});

0 个答案:

没有答案