req.body.emailを使用してjsonデータをキャッチするようにAjaxリクエストを送信すると コンソールの出力が私に未定義です。jquery ajaxでデータ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(" success "、data);' htmlコンテンツを出力しますか? –
yes on sucess ... – shank