Zend Framework 2: Auto disable layout for ajax calls

前端 未结 8 1786
终归单人心
终归单人心 2020-12-16 13:26

An AJAX request to one of my controller actions currently returns the full page HTML.

I only want it to return the HTML (.phtml contents) for that particular action.

8条回答
  •  独厮守ぢ
    2020-12-16 13:56

    aimfeld solution works for me, but in case some of you experiment issues with the location of the template, try to specify the module:

     $this->viewModel->setTemplate('application/ajax/response');
    

提交回复
热议问题