1

I'm trying to delete a model on my backend and what I do is this (the code is adapted just to show you the issue, some parts could be missing):

attending= new Backbone.Model();
attending.url= this.url() + "/reject";
attending.set({
   id: this.id
})

attending.destroy({
   success: function(){
      alert("yes");
   },
   error: function(){
      alert("no");
   }
});

but what I always obtain is a "no" alert. The fact is the backend seems to be updated correctly and what I obtain as a response too. Here it is:

enter image description here

so... what's wrong with the response I get? Why doesn't backbone recognizes it as a successful response? I get 200/OK and a "application/json" format as well!

Bertuz
  • 2,390
  • 3
  • 25
  • 50

2 Answers2

2

Your backend should return something with 200

jQuery expect 200 with application/json to have some content

Have a look here: https://github.com/jashkenas/backbone/issues/2218#issuecomment-20991938

j03w
  • 3,679
  • 1
  • 21
  • 15
  • Thanks! It turned out to be an error that has to do with the empty body (no JSON objects are returned although the headers are well set) – Bertuz Aug 10 '13 at 13:51
0

You might want to place a "debugger;" in the error callback and trace exactly why its coming that route vs the success route. That should atleast get your started on the right path...

Trunal Bhanse
  • 1,651
  • 1
  • 17
  • 27