Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Return a JsonModel from the controller action
- // To send JSON to the client when the Accept header isn’t application/json,
- // we use a JsonModel in a controller action like this:
- namespace Application\Controller;
- use Zend\Mvc\Controller\ActionController;
- use Zend\View\Model\ViewModel;
- use Zend\View\Model\JsonModel;
- class IndexController extends ActionController
- {
- public function indexAction()
- {
- $result = new JsonModel(array(
- 'some_parameter' => 'some value',
- 'success'=>true,
- ));
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement