在我的html页面中,我将此帖子发送到我的sails服务器,但由于req.param()函数没有返回任何有意义的答案,我无法访问控制器中的数据.
这是网页代码
$.post("http://myserver.local/calendar/batch",
{"batch":[
{
"start_date" : "2014-06-27T09:00:00Z",
"title" : "abc",
"attendees" : [
"Fred Bloggs",
"Jimmy Jones",
"The Queen"
],
"event_id" : "123",
"location" : "Horsham, United Kingdom",
"end_date" : "2014-06-27T10:30:00Z"
},
{
"start_date" : "2014-06-27T09:00:00Z",
"title" : "another",
"attendees" : [
"Fred Bloggs",
"Jimmy Jones",
"The Queen"
],
"event_id" : "def",
"location" : "Horsham, United Kingdom",
"end_date" : "2014-06-27T10:30:00Z"
}
]},
function (data) {
console.log("success");
}
).fail(function(res){
console.log("Error: " + res.getResponseHeader("error"));
});
Run Code Online (Sandbox Code Playgroud)
这是控制器
module.exports = {
batch: function …Run Code Online (Sandbox Code Playgroud)