文章詳情頁
html5 - ajax post請求后如何渲染到頁面上
瀏覽:161日期: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中渲染頁面 或者把從數(shù)據(jù)庫中查到的數(shù)據(jù)get到 本人新手 請多包涵
問題解答
回答1:res.json()把數(shù)據(jù)返回到前端,前端通過DOM操作來更改視圖
標(biāo)簽:
Html5
上一條:javascript - 關(guān)于這組數(shù)據(jù)如何實(shí)現(xiàn) 按字母列表分類展示 不改動(dòng)數(shù)據(jù)結(jié)構(gòu)下一條:javascript - 在移動(dòng)設(shè)備上快速滾動(dòng)屏幕然后點(diǎn)擊使?jié)L動(dòng)停止,如何盡量避免在點(diǎn)擊時(shí)誤觸<a>標(biāo)簽,跳轉(zhuǎn)到其他頁?
相關(guān)文章:
1. mysql數(shù)據(jù)庫做關(guān)聯(lián)一般用id還是用戶名2. linux運(yùn)維 - python遠(yuǎn)程控制windows如何實(shí)現(xiàn)3. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認(rèn)選中下拉框的值,傳遞到后臺(tái)消失不見。有圖有代碼,希望有人幫忙4. python小白 關(guān)于類里面的方法獲取變量失敗的問題5. python - 如何對列表中的列表進(jìn)行頻率統(tǒng)計(jì)?6. javascript - 如何用最快的速度C#或Python開發(fā)一個(gè)桌面應(yīng)用程序來訪問我的網(wǎng)站?7. Python2中code.co_kwonlyargcount的等效寫法8. django - Python error: [Errno 99] Cannot assign requested address9. python小白,關(guān)于函數(shù)問題10. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?
排行榜

熱門標(biāo)簽