How to render ZF2 view within JSON response?

OK, i think i finally understood what you’re doing. I’ve found a solution that i think matches your criteria. Though i am sure that there is room for improvement, as there’s some nasty handwork to be done… public function indexAction() { if (!$this->getRequest()->isXmlHttpRequest()) { return array(); } $htmlViewPart = new ViewModel(); $htmlViewPart->setTerminal(true) ->setTemplate(‘module/controller/action’) ->setVariables(array( ‘key’ … Read more