I have a ZF2 application with a method which returns a JSON formatted array using:
$response->setContent(json_encode($reponse));
return $response;
The request is sent via Ajax using jQuery 1.10.2 and when I intercept the response body, using the developer mode or Fiddler, I can see in http://jsonlint.com/ that the JSON is not valid. As a result, my Ajax success callback is triggered with IE8 but with more recent versions or browsers such as Firefox or Chrome, it directly goes to the error callback.
It seems like the invalidity of the JSON is caused by the first curly brackets, when I retype it, it seems okay. I therefore suspect some BOM characters at the beginning of the file.
What is even odder is that, with the exact same source code, my client has no issue at all with Internet Explorer 10 in his environment.
Would you guys have any idea of what could cause such a difference in our PHP/Apache environments?
Thank you for your help. Regards,