Location: PHPKode > scripts > Smart AJAX Controller > ajax.php

	//including the class file
	//Initializing the controller
	//Output buffer will be used to later on return the result in gzip
	$ajax=new SmartAjaxController();
	//If AJAX has submitted a serialized string to be parsed to variables.
		//These variables can be used by $ajax->getVar funtion

	//This is dependant on javascript front-end controller, used as an example
	if(!empty($_POST) && isset($_POST['action'])){
		//this assumes that action is defined by jQuery before being submitted to back-end
			//This is the same example used in javascript file
			case 'alertLowercaseString':
				$ajax->setKey('message','Your string lowercased: '.strtolower($ajax->getVar('string')));

				//If no action is found, execute frontend error callback
				$ajax->setKey('message','This system action does not exist!');

	} else {
		//Since no action was defined or no post was used at all, we simply set the response to return errors to front-end
		$ajax->setKey('message','This system action does not exist!');
	//Here we return the result in gzipped JSON string
	//This also sets proper headers to the file

Return current item: Smart AJAX Controller