当我发送Ajax请求来表示我使用req.body.email来捕获json数据 控制台中的输出给我undefined ....请帮助...jquery ajax到Express无法捕获数据json数据
客户端
$.ajax({
url: '/getRandomPass',
dataType: "json",
data:{'emailId':'[email protected]'},
type: 'POST',
cache: false,
success: function(data) {
console.log("cleint recieved data",data);
// this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.log(xhr,status,err);
}.bind(this)
})
服务器端
app.use(bodyParser.json());
app.post('/getRandomPass', function(req, res) {
console.log("req",req.body.emailId);
});
你设定的响应内容类型? – nikjohn
你的意思是'console.log(“成功”,数据);'输出html内容? –
是成功的...... – shank