首页 新闻 会员 周边

nodejs搭建网站验证成功之后如何跳转

1
悬赏园豆:10 [待解决问题]

我写的后台验证:

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");
    }
});

成功之后是跳转到:

"../views/admin/index.html"这个路径下,并且把对应的参数传过去;
可以前端ajax去返回也这个页面....
该怎样让它跳转呢?如果使用res.redirect()的话也不行,他不能带参数。。。
求教????
卖火柴的大男孩的主页 卖火柴的大男孩 | 初学一级 | 园豆:192
提问于:2017-06-30 16:00
< >
分享
所有回答(1)
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

})

czd890 | 园豆:14412 (专家六级) | 2017-06-30 17:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册