How do you make Zend Framework NOT render a view/layout when sending an AJAX response?

前端 未结 3 2003

Zend\'s documentation isn\'t really clear on this.

The problem is that, by default, Zend automatically renders a view at the end of each controller action. If you\'re us

3条回答
  •  旧时难觅i
    2021-01-30 07:36

    Call this code from within whatever Action(s) is/are going to be sending AJAX responses:

    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender(TRUE);
    

    This disables the Layout engine for that action, and it turns off automatic view rendering for that action. You can then just "echo" whatever you want your AJAX output to be, without worrying about the normal view/layout stuff getting sent along for the ride.

提交回复
热议问题