Zend Framework 2: Auto disable layout for ajax calls

前端 未结 8 1812
终归单人心
终归单人心 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 14:03

    The best is to use JsonModel which returns nice json and disable layout&view for you.

    public function ajaxCallAction()
        {
            return new JsonModel(
                [
                    'success' => true
                ]
            );
        }
    

提交回复
热议问题