I'm doing some experimenting with AJAX in CakePHP and it seems to work except that the view that gets returned includes the default template. How can I get rid of that (or even just specify a different empty template for a view)?
+4
A:
function ajaxFunction() {
//do stuff
$this->layout= 'ajax';
}
Ajax is an included blank layout to prevent extra markup being added, exactly what you want.
seanmonstar
2009-05-05 21:15:33
That is exactly it! Thanks! That layout still includes debug info but now that I look it's just the SQL and not the controller dump which is exactly what I would need . . very cool.
tooshel
2009-05-05 21:41:14
+4
A:
Try using RequestHandler component. This will be handled automatically for you. Then, you can do something like this in your AppController::beforeFilter()
if($this->RequestHandler->isAjax()) {
Configure::write('debug',0);
}
jmcneese
2009-05-10 15:14:49
+1
A:
You will also need to turn off debug output otherwise cake will squirt out all the debug info you usually see at the bottom of the page:
function ajaxFunction() {
//do stuff
Configure::write('debug', 0);
$this->layout= 'ajax';
}
RichardAtHome
2009-05-11 14:29:00