javascript - How to make can.Model send JSON data when update? -


i have code:

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(); 

what expect save put request json in payload, id number:

123123 

the update method signature using function can.model.update: function(id, serialized) -> can.deffered.

so first parameter id , second serialized data.

changing update : function(story) {} update : function(id, story) {} should solve problem.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -