Posts Tagged ‘Zend’

Checking AJAX request in Zend controller

Maybe there are certain actions in Zend that I want to be accessed only with AJAX. This snippet will work:

public function searchAction()
{
        // action body
        $request = $this->getRequest();
	$validate = $request->isXmlHttpRequest();
	//check if it is XMLHttpRequest / AJAX
	if ($validate)
	{
		$this->_helper->layout()->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
                //Do stuff here
	}
}