I did the same as you, I have a controller specifically for processing ajax requests, however my solution is much simpler, I use the init () function, not preDispatch.
My init () function looks like this:
class Ajax_Controller extends Zend_Controller_Action { public function init() { $this->_helper->layout()->disableLayout(); }
What is it! I have not made any other changes from the standard controller.
I will disable rendering rendering in action, if necessary, when I found, in my case I needed a view to render tables, etc. However, if you only ever return json data, then your method of disabling rendering rendering in preDispatch () is perfectly valid.
If I need to return json, I have a similar function for yours and I will turn off rendering rendering.
I used this method on 4 separate but similar projects without any problems. Having said that my ajax calls are usually pretty simple, but I don't see any problems with this method.
If you are looking for a simple, clean ajax implementation, then this may be for you.
source share