Tag Archives: debug

How to hide load time comment for AJAX calls in CakePHP

 CakePHP puts some debug info after page load including the load time of the page. Even though it is an HTML comment line, it does affect returned data for AJAX calls (and not only). 

If we do return JSON, we could set the returned type for json-like and then json_encode the data using the $this->autoRender = false; clause. However, if we expect some specific data (like a boolean yes/no result), we would have problems with the debug feature of CakePHP.

So we could disable the debugging feature of Cake only for AJAX calls adding this statement to the beforeFIlter() action of the app_controller.php:

 

  1. if ( $this->RequestHandler->isAjax() ) {
  2. Configure::write('debug',0);
  3. }

del.icio.us Digg DZone Facebook Google Google Reader Magnolia reddit SlashDot Technorati ReadMe.ru Dobavi.com Dao.bg Lubimi.com Ping.bg Pipe.bg Svejo.net Web-bg.com