search

Home  >  Q&A  >  body text

html5 - How to render to the page after ajax post request

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

天蓬老师天蓬老师2742 days ago1012

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-24 11:38:50

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

    reply
    0
  • Cancelreply