html5 - How to render to the page after ajax post request
天蓬老师
天蓬老师 2017-05-24 11:36:50
0
1
1036
router.post('/goods/tejia',function(req,res,next){
    var gid = req.body.gid;
    console.log(gid);
    User.find({
        gid :gid
    }).then(function(goodsInfo){
        console.log(goodsInfo);
        //  res.render('main/goods',{
        //       goodsInfo : goodsInfo
        //  })
    })
})
router.get('/',function(req,res,next){
       console.log(req.goodsInfo);
       res.render('main/goods',{
              goodsInfo : req.goodsInfo
         })
})

The question is how to render the page in post or get the data found from the database. I am a newbie, please bear with me

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
Ty80

res.json() returns the data to the front end, and the front end changes the view through DOM operations

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