2013-04-25 107 views
0

所以我工作的一个应用程序,我尽到一个控制器一些Ajax调用,并在没有数据的情况下,抛出了404Zend公司抛404头发展模式

throw new Zend_Controller_Action_Exception('This page does not exist', 404); 

的问题是,我有$this->frontController->throwExceptions(true);所以在开发模式中会抛出一个错误,但它没有设置404头,并且我需要头,因为在基于头的ajax调用中,我知道接下来会发生什么。

有没有办法在开发模式下抛出404头,throwExceptions设置为true

回答

0

解决的办法是拨打:->sendHeaders();

$this->getResponse()-> setHttpResponseCode(405)-> setRawHeader('HTTP/1.1 405 Method Not Allowed')->sendHeaders();