title: JSON.parse() does not work when content-type is set to application/json
body: <p>I am running into a jquery (bug/error) when trying to parse a JSON string returned from the server: </p>
  
  <pre><code>Timestamp: 10/04/2013 21:05:12
  Error: SyntaxError: JSON.parse: unexpected character
  Source File: http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  Line: 3
  </code></pre>
  
  <p>and I noticed that the JSON.parse works fine when the header Content-type is not set to 'application/json' but does not work if Content-type is set to json. any idea why this would happen? </p>
  
  <p><strong>Not Working Code:</strong> </p>
  
  <p><strong>Controller code:</strong></p>
  
  <pre><code>  $response = array('data' =&gt; array('msg' =&gt; 'Form did not validate'), 'response_handler_fn' =&gt; 'sign_up_response_handler_fn');
    $this-&gt;getResponse()-&gt;setHttpHeader('Content-type','application/json');
    return $this-&gt;renderText(json_encode($response));
  </code></pre>
  
  <p><strong>Javascript:</strong> </p>
  
  <pre><code>// ...
  success: function( response ) {
  var responseData = $.parseJSON(response);
  }
  </code></pre>
  
  <p><strong>Headers</strong></p>
  
  <pre><code>Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Connection  Keep-Alive
  Content-Length  92
  Content-Type    application/json
  Date    Wed, 10 Apr 2013 20:05:12 GMT
  Expires Thu, 19 Nov 1981 08:52:00 GMT
  Keep-Alive  timeout=15, max=100
  Pragma  no-cache
  Server  Apache
  X-Powered-By    PHP/5.3.5
  </code></pre>
  
  <p><strong>Response:</strong> </p>
  
  <pre><code>{"data":{"msg":"Form did not validate"},"response_handler_fn":"sign_up_response_handler_fn"}
  </code></pre>
  
  <p><strong>Code that Does Work</strong></p>
  
  <p><strong>Controller:</strong> </p>
  
  <pre><code>  $response = array('data' =&gt; array('msg' =&gt; 'Form did not validate'), 'response_handler_fn' =&gt; 'sign_up_response_handler_fn');
    return $this-&gt;renderText(json_encode($response));
  </code></pre>
  
  <p>Javascript the same as the one which does work</p>
  
  <p>Headers: </p>
  
  <pre><code>Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Connection  Keep-Alive
  Content-Length  92
  Content-Type    text/html; charset=utf-8
  Date    Wed, 10 Apr 2013 20:09:04 GMT
  Expires Thu, 19 Nov 1981 08:52:00 GMT
  Keep-Alive  timeout=15, max=100
  Pragma  no-cache
  Server  Apache
  X-Powered-By    PHP/5.3.5
  </code></pre>
  
  <p>Response: </p>
  
  <pre><code>{"data":{"msg":"Form did not validate"},"response_handler_fn":"sign_up_response_handler_fn"}
  </code></pre>