我写的后台验证:
router.post("/user/login/check", function(req, res, next) {
//登录验证
let username = req.body.username;
let password = req.body.password;
if (username == "admin" && password == "12345") {
res.render("../views/admin/index.html",{username : username});
} else {
res.end("0");
}
});
成功之后是跳转到:
node:
routor.post(....,function(){
res.send({status:200,url:'//admin/index.html'})
})
ajax:
$.post(...,function(data){
if(data.status===200) window.location.hef=data.url
})