More information about this topic
Reset database
 | 
Advanced ajax request using ajaxLink

protected/modules/AjaxModule/views/ajax/ajax_request_advanced.php


echo CHtml::ajaxLink(
	'Test request',          // the link body (it will NOT be HTML-encoded.)
	array('ajax/reqTest02'), // the URL for the AJAX request. If empty, it is assumed to be the current URL.
	array(
		'update'=>'#req_res'
	)
);
?>

<div id="req_res">...</div>


protected/modules/AjaxModule/controllers/AjaxController.php

	public function actionReqTest02() {
		$date = date('H:i:s');

		$this->renderPartial('actionReqTest02', array('date'=>$date));

		Yii::app()->end();
	}

protected/modules/AjaxModule/views/ajax/actionReqTest02.php

<?php
// You can work with the variable passed to the view file
?>
<input id="btnAlertDate" type="button" value="Alert date" />
<script type="text/javascript">
$('#btnAlertDate').click(function(){
	alert('<?php echo $date; ?>');
});
</script>
Fork me on GitHub