CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. CakePHP provides several Ajax features, but if cakephp debug is not turned off, most Ajax calls and JSON encoding would fail.
The problem / symptoms
When calling a server side cakephp method through Ajax calls usualy in combination with JSON encoding, the call fails. The server returns HTTP 200 and everything seems fine, but the Ajax call just doesn’t work.
Diagnostic
By default, cakePHP adds debug information to it’s HTML output. This debug information is very useful, but also very disruptive to Ajax calls and JSON parsing.
The solution
Turn debug off by setting it to 0 – There are two ways you can do that:
1) For the entire cakephp application – go to core.php under the app/config folder and replace this line “Configure::write(‘debug’, 2);” with this line “Configure::write(‘debug’, 0);”
2) For only a specific method call – add this line to your relevant method in the controller –
function yourAjaxCallMethod() {
Configure::write(‘debug’, 0);
…
}