3
有什麼方法可以使正確的JSON輸出工作嗎? (替代$此 - > _ heleper-> json-> SendJSON()在ZF1)在沒有模板渲染的情況下在ZF2中正確輸出JSON
public function ajaxSectionAction() {
return new JsonModel(array(
'some_parameter' => 'some value',
'success' => true,
));
}
Bacause它拋出一個錯誤:
> Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException'
> with message 'SmartyModule\View\Renderer\SmartyRenderer::render:
> Unable to render template ...
這是混亂的方式,我看不出這和Zend_Json :: encode()之間的優點 – ShiftedReality
我更新了答案。最好的方法是JsonModel並查看策略。但是你可以使用Response來返回每個數據,比如json。 –