运维网's Archiver
论坛
›
nodejs
› nodejs的http和json返回
lchl0388
发表于 2017-2-21 09:58:08
nodejs的http和json返回
nodejs搭建服务器,
res.end():介绍数据返回,不然客户端会一直等待数据返回结束
req.on('end',function()):客户端请求结束时触发
nodejs返回json数据可以用函数res.json();
如:
res.json({success: true,message:"登入成功"});
前台得到json数据:
{“message":”登入成功“,"success":true}
页:
[1]
查看完整版本:
nodejs的http和json返回