我正在使用控制器并使用ajax发送路由呼叫但在路由中我无法在req.body中获得任何值。例如我提到:
App.StudentController = Ember.Controller.extend({
// initial value
isExpanded: false,
actions: {
studentLogin: function() {
var data = {"rollnumber":this.get("rollnumber"),"password" :this.get("password")};
Ember.$.ajax({
url: '/rollnumber',
method: "GET",
contentType: 'application/json',
data: data,
success: function (data) {
console.log(data);
}
});
},
}
});
和路线是:
router.get("/rollnumber",function(req,res,next) {
console.log(req.body);
var roll = {"rollnumber":req.body.rollnumber};
console.log("test get data",roll);
});
IN req.body我得到{} Json。