title: Backbone.js Uncaught TypeError: Cannot use 'in' operator to search for 'id' in etc to copy json data
body: <p>I have a backbone.js error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot use 'in' operator to search for 'id' in
    {"websiteID":"2","title":"titre site 2"} backbone-min.js:9</p>
  </blockquote>
  
  <p>I am trying to copy json data (received from ajax) into an instance of a Model.</p>
  
  <p>How can I fix this problem?</p>
  
  <p>My code is:</p>
  
  <pre><code>var Website = Backbone.Model.extend({
      // set default json data in the website:
      defaults: {"websiteID":"1","title":"default title"}
  });
  
  var website = new Website();
  
  function UpdateWebsiteBasedOnDBData() {
    this.url = 'script.php';
  }
  
  UpdateWebsiteBasedOnDBData.prototype.readData = function(dataToGet) {
          return $.ajax({
          type: "GET",
          url: this.url,
          data: dataToGet,
          context: this,
          success: this.onSuccess
        });
  };
  
  UpdateWebsiteBasedOnDBData.prototype.onSuccess = function(data) {
      website.set(data);
      alert( website.get("websiteID") );
  };
  
  $(document).ready(function() {
      var updateWebsiteBasedOnDBData = new UpdateWebsiteBasedOnDBData();
      updateWebsiteBasedOnDBData.readData({"websiteID": 2});
  });
  </code></pre>
  
  <p>The script.php returns proper json:</p>
  
  <p>{"websiteID":"2","title":"titre site 2"}</p>
  
  <hr>
  
  <p><strong>Update</strong>:</p>
  
  <p>I still need to check but I strongly suspect my json to actually not be valid.
  Root cause could be (still to be verified) the character set of my php script.</p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/2475113/weird-character-at-start-of-json-content-type">Weird character at start of json content type</a></p>