我有这个代码:
var SotriesModel = can.Model.extend({
findAll: 'GET /api/stories/',
create: function(story) {
console.log(story)
return $.ajax({
url: '/api/stories/',
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(story)
});
},
update : function(story) {
console.log(story)
return $.ajax({
url: '/api/stories/',
type: 'PUT',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(story)
});
},
destroy: 'DELETE /api/stories/{id}'
}, {});
var story = new SotriesModel({id:123123, name:"test"});
story.save();
我对保存的期望是一个带有 JSON 的 PUT 请求,但我得到的只是 id 号:
123123