Hi there,

So I'm getting a little confused with how to return some html in an AJAX request from Zend. Actually It's pretty straightforward to do it, but I refactored my view to include child views.

Here's my original script:
PHP Code:
$view = new ViewModel(array($bat => 'bat'$baz => 'baz');
$view->setTemplate('foo');

$child = new ViewModel();
$child->setTemplate('bar');

$view->addChild($child);

$htmlOutput $this->getServiceLocator()->get('viewrenderer')->render($view);

return 
$response->setContent(Json::encode(array('html' => $htmlOutput))); 
Which worked fine, except that the child view wasn't rendered.

So I tried to use the PhpRenderer:
PHP Code:
$renderer = new PhpRenderer();
$htmlOutput $renderer->render($layout);

return 
$response->setContent(Json::encode(array('html' => $htmlOutput))); 
And I got the following error:
Unable to render template "foo"; resolver could not resolve to a file

So I added a resolver:
PHP Code:
$renderer = new PhpRenderer();

$resolver = new Resolver\TemplatePathStack();
$resolver->setPaths(
    array(
'foo' => 'path/to/foo.phtml');
);

$renderer->setResolver($resolver); 
$htmlOutput $renderer->render($layout);

return 
$response->setContent(Json::encode(array('html' => $htmlOutput))); 
But I get the same error.

Can anyone shed any light on this?

Many thanks,
Mike