how to use ajaxLink to perform a controller action

i want to use ajax link to perform a controllers action. i-e

i have a groups controller and i have an ajaxLink on it ( can’t figure out how to send the data through ajaxLink to groupMembers create action )

what i want is when the user clicks the ajax button a dialogbox should open and it may have confirmation button and captcha.

can anyone help me out with this situation???

try to use an ajaxSubmitButton

I think this is very close to what you want:


thanx i had a look at it i think i will be able to understand it properly

so far after reading this(topic) i have came across this

in the groups view

echo CHtml::ajaxLink(Yii::t('Groups','Join Group'),






        'complete' => 'function(){




                    // handle return data

                   // alert( 'welcome' );

                    alert( data ); // it does alert the data

                    $('#joinGroup').replaceWith(data); // if i comment this no data is show even if i m using 'update'=>'#joinGroup'




        'update'=>'#joinGroup' // joinGroup is a div in the view



in the groupmembers controller

 public function actionCreate()


	       $groupID = $_POST['groupID'];

           $userID = $_POST['userID'];


           $model=new Groupmembers;

           $model->group_id = $groupID;

           $model->user_id = $userID;


       	// Uncomment the following line if AJAX validation is needed


         // Flag to know if we will render the form or try to add 

        // new member.








                    echo "welcome data is saved";


    			 echo "model not saved";







    	           	),false, true);



and this the view (_formDialog) which is called in this view function

<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(


	// additional javascript options for the dialog plugin


		'title'=>'Join This Group',







<h1>Join Group</h1>

<!-- echo 'dialog content here';-->

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(



)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">

		<?php echo $form->labelEx($model,'group_id'); ?>

		<?php echo $form->textField($model,'group_id'); ?>

		<?php echo $form->error($model,'group_id'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'user_id'); ?>

		<?php echo $form->textField($model,'user_id'); ?>

		<?php echo $form->error($model,'user_id'); ?>


      <?php if(CCaptcha::checkRequirements()): ?>

	<div class="row">

		<?php echo $form->labelEx($model,'verifyCode'); ?>


		<?php $this->widget('CCaptcha'); ?>

		<?php echo $form->textField($model,'verifyCode'); ?>


		<div class="hint">Please enter the letters as they are shown in the image above.

		<br/>Letters are not case-sensitive.</div>

		<?php echo $form->error($model,'verifyCode'); ?>


	<?php endif; ?>

    <div class="row">




        echo CHtml::ajaxSubmitButton(Yii::t('Groups','Join Group'),


        array('success'=>'function(data) {









        echo CHtml::normalizeUrl(array('groupmembers/create'));



<?php $this->endWidget(); ?>

</div><!-- form -->



// the link that may open the dialog

echo CHtml::link('Join Group Now', '#', array(

	'onclick'=>'$("#mydialog").dialog("open"); return false;',



now the main issues are:


[*]when i click on the join button it properly loads the dialog rendered from the controller but when i click on the submit button nothing happens

[*]as i have used the captcha too i no captcha or wrong captcha is entered or even no value is entered in any field the form is not validated and no errors are shown

[*]even if i input the right values in the form it is still not submitted, nothing happens


can anyone plz tell me where i might be createing wrong logic or how to do it properly ?