<?php
echo  CHtml::ajaxSubmitButton(
		$model->isNewRecord ? 'Submit' : 'Save',     CHtml::normalizeUrl(array('post/ajaxComment','id'=>$post->id)),
		array(
			'beforeSend'=>'function(){
			/*you code*/
			}',
			'success'=>'function(data){
			/*you code*/
			}',
		)
	);
?>

controller中

if(Yii::app()->request->isAjaxRequest){
//... you code... 
} 
else{
	Yii::app()->user->setFlash(...);
	$this->redirect(...); 
}