文章详情页
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到 本人新手 请多包涵
问题解答
回答1:res.json()把数据返回到前端,前端通过DOM操作来更改视图
标签:
Html5
上一条:javascript - 关于这组数据如何实现 按字母列表分类展示 不改动数据结构下一条:javascript - 在移动设备上快速滚动屏幕然后点击使滚动停止,如何尽量避免在点击时误触<a>标签,跳转到其他页?
相关文章:
1. dologin说是没有定义2. 问一下代码哪里出错了????3. mysql - 数据库建字段,默认值空和empty string有什么区别 1104. 冒昧问一下,我这php代码哪里出错了???5. python - UTC格式转换成本地时间6. angular.js - 在ionic下,利用javascript导入百度地图,pc端可以显示,移动端无法显示7. 求问:其它输出都正常,就是错误输出是乱码!8. mybatis - Java关于Mysql的随机id生成9. windows - Mysql数据库部署 能否不安装服务?10. python - 如何使用requests模块在一个post中提交含有多个相同名称的数据?
排行榜