I believe by default, Cake does not run Ajax requests through the main layout, so MOST html should not be there. If not, you can force what layout can be used by specifically calling the render method for a controller and setting the layout to 'ajax'. Reference: http://book.cakephp.org/view/57/Controller-Methods#render-428
I also had issues with debug turned on, because all the SQL statements were getting logged to an HTML table at the bottom of AJAX requests, and caused some serious parsing issues when the data type was expected to be AJAX. This is probably a hack, but I did the following to get around it.
In the main AppController in the beforeFilter() I added the following (make sure all your other controller's beforeFilter methods call the parent method):
if ($this->RequestHandler->isAjax()) {
$db =& ConnectionManager::getDataSource('default');
$db->fullDebug = false;
}
In cake/libs/model/datasources/dbo_source.php at roughly line 2074 in my version, I changed
if (Configure::read() > 1) {
$this->showLog();
}
to
if (Configure::read() > 1 && $this->fullDebug) {
$this->showLog();
}