I am developing a web application using backbonejs v 0.5.3 + jquery v 1.6.4. On the backend side I use jboss rest easy on jboss AS 7.0.2.
When I try to fetch a model everything works well but when I try to update a model the error callback function is called every time. Here is my js code:
save : function() {
this.model.save({id : this.model.get('id')}, {
success : function(model, resp) {
alert('success');
},
error : function(model, resp) {
alert('error');
}
});
},
The strange thing is: if I try to debug the javascript code the success alert is shown. In normal executions the error alert is displayed (I got the same behavior on Chrome and Firefox).
Any thought on this?
Thank you in advance!
What is your service returning on the POST/PUT save operations?
Make sure that the server is returning the JSON representation of your object in the body... or at least a JSON representation of the fields that changed. Especially make sure the ID field is sent back as Backbone will use it later when updating or deleting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With