Some people have been asking me how to disable the layout and view renderer in Zend Framework so an action in a given controller returns only JSON. Well, to do this, just use two lines of code, as you can see below.
This first approach disables the layout and view renderer for all actions in a given controller:
| |
However, this second approach disables the layout and view renderer for only one action, in this case “index”:
| |