Return to Snippet

Revision: 37041
at December 3, 2010 02:36 by nikefido


Initial Code
<?php

/******************************************
	App Async Controller for AJAX functionality
	
	Module: App
	Controller: Async
	
	
******************************************/

class App_AsyncController extends Zend_Controller_Action {
	
    public function init() {
    	//Set no views to render in any action
    	//You may wish to change this if you want to use a view file
    	$this->getHelper('viewRenderer')->setNoRender();
    	
    	//Ensure this is an AJAX request
    	if(!$this->_request->isXmlHttpRequest()) {
    		die(); //You may want to throw an Exception instead
    	}
    }
    
    public function someAction() {
    	//Disable the layout.
    	$this->getHelper('layout')->disableLayout();
    }
}

Initial URL


Initial Description
Example controller used for AJAX requests - Disables layout, shows how to sent an action to not render a view (setNoRender) and adds some security checks.

Initial Title
Zend ajax controller  - testing if ajax, turning off layout and disabling view file

Initial Tags


Initial Language
PHP