title: Unexpeced token error when setting contentType to application/json
body: <p>I am sending data using AJAX POST. The data is JSON format. See below. However, I keep getting <strong>'Unexpected token u in JSON at position 0'</strong>. Why is this happening? The reason I am setting contentType here is so that the Boolean field <code>checked</code> does not get converted to string. </p>
  
  <pre><code>var data = {
    "user": "tom",
    "number": 9,
    "checked": false
  }
  
  $.ajax({
      url: url,
      method: "POST",
      data: data,
      contentType: 'application/json',
      dataType: 'json',
      beforeSend: function (xhr) {
          xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
      },
      success: function (success) {
          console.log("success");
      }
  });
  </code></pre>