/ Published in: PHP
Expand |
Embed | Plain Text
<?php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $this->getHelper('ViewRenderer')->setNoRender(true); $this->getHelper('json')->sendJson($values); } }
Comments
Subscribe to comments
You need to login to post a comment.

I think if you have a AjaxController by example, in the init() you can write this: $this->_helper->AjaxContext()->addActionContext('ajax-handler', 'json')->initContext('json');
Now all data transmitted to the view will be converted into JSON format. This method is preferable to manually turn off the view and convert data to JSON.
I think if you have a AjaxController by example, in the init() you can write this:
$this->_helper->AjaxContext()->addActionContext('ajax-handler', 'json')->initContext('json');Now all data transmitted to the view will be converted into JSON format. This method is preferable to manually turn off the view and convert data to JSON.