亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

node.js - How to jump to the page after a few seconds after express renders the page?
女神的閨蜜愛(ài)上我
女神的閨蜜愛(ài)上我 2017-06-24 09:43:30
0
2
1229
  1. I just started learning express and there is a login page. If the verification fails, it will display "The username or password is wrong, please log in again!", and then the page will redirect to the login page after a few seconds, but it has no effect. :

var express = require('express');
var router = express.Router();

router.post('/', function(req, res){
    var username = req.body.user;
    var password = req.body.password;

    if(username === 'liaoyf' && password === '123'){
        res.send('Welcome!' + username);
    }else{
        res.send('用戶名或密碼錯(cuò)誤!請(qǐng)<a href="/">重新登錄</a>');
        //這邊我想重定向到登錄頁(yè)(登錄頁(yè)路徑為/)
        setTimeout(function(){
            res.redirect('/');
        }, 2000);
    }
});

module.exports = router;

Looking online, it seems that send is completed directly and will not be triggered later. So what should be done?

女神的閨蜜愛(ài)上我
女神的閨蜜愛(ài)上我

reply all(2)
習(xí)慣沉默
res.set('refresh', '5;url=http://example.com/');

Or add

in HTML
<meta http-equiv="refresh" content="5;url=http://example.com/" />
淡淡煙草味

You can use res.write() for the previous error message. This will not end the response like send() or end().

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template