varoption={type:"POST",url:"/",contentType:"application/json;charset:utf-8",dataType:"json",data:{ok:"on",temperature:"18",}success:function(response){console.log(response);}error:function(err){alert(err);}}$.ajax(option);以上是前臺(tái)代碼。。app.post("/",function(req,res){vardata={ok:req.body.ok,temperature:req.body.temperature}console.log(data);})最后輸出的為{ok:undefined,temperature:undefined}我使用的express框架.app.use(bodyParser());app.use(bodyParser.json());app.use(bodyParser.urlencoded({extended:true}));使用的bodyParser解析的模塊。但是依然解析不到req.body里面的值。
express4.x 框架 req.body獲取不到前臺(tái)post數(shù)據(jù)
海綿寶寶撒
2019-04-10 20:49:11