title: Why doesn't jQuery.parseJSON() work on all servers?
body: <p>Hey there, I have an Arabic contact script that uses Ajax to retrieve a response from the server after filling the form.</p>
  
  <p>On some apache servers, <code>jQuery.parseJSON()</code> throws an <code>invalid json</code> excepion for the same json it parses perfectly on other servers. This exception is thrown only on chrome and IE.</p>
  
  <p>The json content gets encoded using php's <code>json_encode()</code> function. I tried sending the correct header with the json data and setting the unicode to utf-8, but that didn't help.</p>
  
  <p>This is one of the json responses I try to parse (removed the second part of if because it's long):</p>
  
  <p><code>{"pageTitle":"\u062e\u0637\u0623 \u0639\u0646\u062f \u0627\u0644\u0625\u0631\u0633\u0627\u0644 !"}</code></p>
  
  <p><em>Note</em>: This language of this data is Arabic, that's why it looks like this after being parsed with php's <code>json_encode()</code>.</p>
  
  <p>You can try to make a request in the examples given down and look at the full response data using firebug or webkit developer tools. The response passes <a href="http://www.jsonlint.com/" rel="nofollow">jsonlint</a>!</p>
  
  <p>Finally, I have two urls using the same version of the script, try to browse them using chrome or IE to see the error in the broken example.</p>
  
  <p><strong>The working example</strong> : <a href="http://namodg.com/n/" rel="nofollow">http://namodg.com/n/</a></p>
  
  <p><strong>The broken example</strong>: <a href="http://www.mt-is.co.cc/my/call-me/" rel="nofollow">http://www.mt-is.co.cc/my/call-me/</a></p>
  
  <p><strong>Updated:</strong> To clarify more, I would like to note that I manged to fix this by using the old <code>eval()</code> to parse the content, I released another version with this fix, it was like this:</p>
  
  <pre><code>// Parse the JSON data
  try
  {
      // Use jquery's default parser
      data = $.parseJSON(data);
  }
  catch(e)
  {
      /*
       * Fix a bug where strange unicode chars in the json data makes the jQuery
       * parseJSON() throw an error (only on some servers), by using the old eval() - slower though!
       */
      data = eval( "(" + data + ")" );
  }
  </code></pre>
  
  <p>I still want to know if this is a bug in jquery's <code>parseJSON()</code> method, so that I can report it to them. </p>