weixin_33743703 2016-08-17 22:31 采纳率: 0%
浏览 67

用ajax POST传递数据

submit() {
    $.ajax({
        url: 'http://localhost:5000/data',
        type: 'POST',
        data: JSON.stringify({ Markers: 'heleeo' }),
        contentType: "application/json",
        dataType: 'json',
        success: (data) => {
            alert(data);
        },
        error: () => {
            console.log('wrong');
        }
    });

}

when trying to access it with my node.js server it throws an error saying markers is undefined

apiRoutes.post('/data', function(req, res) {
  console.log(req.body.Markers);
});
  • 写回答

0条回答 默认 最新

    报告相同问题?