I\'m trying to update a record in DB so I\'m defining model with data and calling .save() method. The PUT request is triggered and the database entry is updated. The problem
Just found similar problem where the issue was solved. You have to put something as first parameter (I put null since my model was already populated with data explicitly) and object with callbacks as second. So something like;
sessionsModel.save(null, {success:function() {} });
Your server must return a JSON object. If the response is not a JSON object, the callbacks will not fire. Check this solution https://stackoverflow.com/a/22176044/1579718
I was suffering this issue - but was struggling because my server was responding with a valid JSON object (the model) and I was already using null
in my save call.
As I (eventually) found, before the success callback is fired, the returned model is passed through the validate method. In my case I had a (obvious when you're looking in the right place) problem which caused the returned model to be deemed invalid and subsequently prevent the success callback.
Whilst I appreciate this doesn't help the OP, I post this in the hope it helps someone else having the same issue.
While searching on this, I first landed on this SO thread which did not work for me, but seemed to work for other, later on I bumped into this link, where some one had tried null
instead of {}
as the first parameter.
this.model.save(null, {
success: function (model, response) {
console.log("success");
},
error: function (model, response) {
console.log("error");
}
});
so, this worked for me. Hope this helps you too.