Clean Ajax controller implementation in Zend Framework

后端 未结 4 780
独厮守ぢ
独厮守ぢ 2021-02-10 08:48

I need a controller in my Zend Framework project, which should handle only ajax requests.

My approach at the moment is to extend the Zend_Controller_Action:



        
4条回答
  •  天命终不由人
    2021-02-10 09:55

    You can simply use

    $this->_helper->json($data);
    

    wherever you like. It disables everything not needed, clears the response, encode data to json, sends the response and set propper headers as a bonus. This is the most "zend-way" there is I guess ;)

提交回复
热议问题