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)?
From stackoverflow
-
function ajaxFunction() { //do stuff $this->layout= 'ajax'; }Ajax is an included blank layout to prevent extra markup being added, exactly what you want.
http://book.cakephp.org/view/96/Layouts
tooshel : 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. -
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); } -
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'; }
0 comments:
Post a Comment