0

可能重复:
如何在 JSON 响应中呈现 ZF2 视图?

我必须更新已将其设置为视图策略 ViewJsonStrategy 的 Zend 控制器。

通常我有

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

    return $e;

一切顺利。但例如我还需要渲染一些 html。例如:

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

这根本不起作用。我怎样才能做到这一点?

4

0 回答 0