文章詳情頁
html5 - ajax post請求后如何渲染到頁面上
瀏覽:159日期:2022-12-05 09:31:27
問題描述
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到 本人新手 請多包涵
問題解答
回答1:res.json()把數據返回到前端,前端通過DOM操作來更改視圖
標簽:
Html5
上一條:javascript - 關于這組數據如何實現 按字母列表分類展示 不改動數據結構下一條:javascript - 在移動設備上快速滾動屏幕然后點擊使滾動停止,如何盡量避免在點擊時誤觸<a>標簽,跳轉到其他頁?
相關文章:
1. html - 微信瀏覽器h5<video>標簽問題2. angular.js - angularjs如何傳遞id給另一個視圖 根據id獲取json數據?3. css3 - 圖片等比例縮放4. javascript - setIndex的作用5. python - 我想把下面代碼中的多余空白行去除該怎么做,如何用正則實現6. android - Windows系統下運行react-native App時,報下面的錯誤?7. 黑客 - Python模塊安全權限8. python - tweepy 庫 連接Twitter API 報錯9. android 微信是如何實現即時更新好友頭像的10. node.js - 為什么微信的消息MsgId出現重復了,無法排重了。。
排行榜
