Last few articles in this blog are only for stupid problems and unfortunately this one will be the same.
I had to use JSON to update some chained select boxes. I am using one jQuery plugin for this. The problem is that if you code, most likely your debug setting in the core.php file is set to 1 (or 2). This way the developer can see errors from CakePHP.
When the level is set to 1, at the end of the page, there is an comment, displaying the processing time for the page, but when you use JSON, this comment causes troubles (probably, because JSON doesn’t accept this type of comments) and the JS fail to process the response.
In order to check JSON, I needed to disable set debug level to 0 and after this to reset it again to 1 (for debugging purposes in other parts of the application).
So, the conclusion: bear in mind, that JSON doesn’t like HTML comments.
Hope this helps.
Thanks for the hints Abba Bryant, actually I knew about setting the Configure::write(’debug’, 0); for the specific action, but it was annoying for the first time 🙂
About parseExtensions – I’ve read about it, but I’ve never used it, I should try…
Thanks again!
An alternative to what Abba described is to modify app/webroot/index.php and to remove the output of the processing time from the end of this file.
That’s true Daniel, but I hate to touch into files which should not be touched 🙂
As long as you know what you do I don’t see any problems in editing this file: the file is in the app folder and if you use an advanced installation you have to touch it anyway.
You are right, it’s in APP, probably I need to touch, because I am tired from switching on and off debug, as well as I haven’t used this parsing time anyway. 🙂