0

Possible Duplicate:
How to render ZF2 view within JSON response?

I have to update a Zend controller that has set it up as view strategy ViewJsonStrategy.

Usyally I have

    $result = new JsonModel($result);
    $e->setResult($result);

    return $e;

and everything goes well. But for example I need also to render some html. For example:

$result = new JsonModel($result);
if($someFlag)
{
    $result = "<html><body>Html message</body>";
}
$e->setResult($result);
return $e;

This does not work at all. How can I do that?

Community
  • 1
  • 1
catalinux
  • 1,462
  • 14
  • 26
  • 1
    html and json renderer can't be mixed, in your case use Javascript in the client side to phrase the Json result to update the browser view – Raj Jan 15 '13 at 18:52
  • My request has to be 90% json. Some times, when I uplaod a file, my response will be in an iframe (i can't use ajax for files) – catalinux Jan 15 '13 at 20:06
  • you can do this by adding a parameter with each request from the client to distinguish Json and html and output the response based on the parameter value for either json or html, I do this by adding a json=1 paramenter to the request, checking this I send Json output – Raj Jan 16 '13 at 05:57

0 Answers0