【发布时间】:2018-02-19 07:18:05
【问题描述】:
这是我的 ajax 请求调用
$.ajax({
url: '/refresh',
type: 'GET',
contentType: "application/json",
data: {
Name: $("#inputName").val(),
Url: $("#inputUrl").val()
},
success: function(data) {
console.log('form submitted.' + data);
}
});
这是nodejs中的GET路由
app.get('/refresh', function(req, res) {
console.log("My data" + JSON.stringify(req.body));
//other operations
}
如何在我的 js 中获取从 ajax 调用传递的数据?请帮忙!!非常感谢!
【问题讨论】:
-
你有什么错误吗?
-
您正在发出 GET 请求,没有请求正文来描述其内容类型。声称请求的内容类型是 JSON 是错误的。
标签: javascript node.js ajax express