title: Backbone sync error even after response code 200
body: <p>Hello Backbone ninjas,</p>
  
  <p>This is my first time using Backbone - so please excuse my "noob"ness. 
  In my functionality (part of a larger app),I have a Backbone View vA, backed by a model mA (as it should be ) and the server side is in Spring MVC having annotated Spring controller methods with @RequestBody and @ResponseBody. I've got Jackson working fine with Spring.</p>
  
  <p>Now, in the app, </p>
  
  <pre><code>Backbone.Model
   |_ BaseModel (custom base model for our app)
     |_ mA (my model)
  </code></pre>
  
  <p>mA has its own endpoint and it Backbone sucessfully calls that when making a PUT request i.e., when I call save() from a submit button event handler from View vA like so:</p>
  
  <p>this.model.save({</p>
  
  <pre><code>            success : function(){
  
                      alert('Request submitted successfully');
  
  
              },
  
              error : function(){
                  alert('Something awful happened.');
              }
  </code></pre>
  
  <p>});</p>
  
  <p>Our BaseModel has the following:</p>
  
  <pre><code>define([], function() {
  
  
  
  window.BaseModel = Backbone.Model.extend({
   ......
  
  
  });
  
  onSyncError : function(model, response) {
          switch (response.status) {
          case 403:
          [...//some more code ]
          default:
              alert(bundle.getDefault('HTTP_RESP_OTH') + response.status);
          }
      },
  
      onSyncSuccess : function(model, response) {
          alert('Sync done! ');
      },
  
      sync : function(method, model, options) {
          options.error = this.onSyncError;
          Backbone.sync.call(this, method, model, options);
          ....//some more stuff.      
      },
  
  }
  </code></pre>
  
  <p>Spring controller method:</p>
  
  <pre><code>@RequestMapping(value="/resource/xyz/{id}.json", method = RequestMethod.PUT, consumes     = {"application/json"}
  , produces = {"application/json"})
  @ResponseBody
  public Map&lt;String,String&gt; methodX(@RequestBody XyzDTO  xyzDTO){
  ....
  map.put("msg", "success");
  
  return map;
  }
  </code></pre>
  
  <p>Also, right before I make the save call, I modify a few Model attributes, since the server side DTO has a different structure like so:</p>
  
  <pre><code>this.model.unset("abc",{ silent: true });
  this.model.set( { abc: {id : "2",xyz:{ ... //more code } ); 
  </code></pre>
  
  <p>The issue is, calling save() generates a PUT request and successfully calls the Spring endpoint handler, but I get a response code 200 (which is what I expect),
  but when I trace the call with Firebug, it goes into the onSyncError method and gives me an error message (because of the "default" case in it).</p>
  
  <p>The Backbone doc says : "When returning a JSON response, send down the attributes of the model that have been changed by the server, and need to be updated on the client". Well, I don't need to update the model on the client side, its one of the last screens and I just need to tell the user of a success / error and 
  redirect him to a main page/dashboard. </p>
  
  <p>I read up some more, and it seems code 200 as response is not sufficient - there might be JSON parsing errors causing the sync to fail.</p>
  
  <p>I checked the response in Firebug, and the response JSON looks like {"msg":"Success"}. </p>
  
  <p>So, what could be going wrong?</p>