首頁  >  問答  >  主體

html5 - ajax post請求後如何渲染到頁面上

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

問題是如何在post中渲染頁面 或把從資料庫查到的資料get到 本人新手 請多包涵

#
天蓬老师天蓬老师2704 天前980

全部回覆(1)我來回復

  • PHP中文网

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

    res.json()把資料傳回前端,前端透過DOM操作改變視圖

    回覆
    0
  • 取消回覆