ajaxbutton

My code:


<?php

         echo CHtml::ajaxButton ("All",CController::createUrl('user/grantAllRoles',array('user'=>$model->idUser)), 

                    array('type' => 'POST',

                          'data' =>array('userrole'=>$model),  

                        ),array('id'=>'selectAll')

                 );

         

                ?>

My browser answer:

you’re not allowed to perform this action.

why?

Add acces in your user controller


public function accessRules()

	{

		return array(

			array('allow',  // allow all users to perform 'index' and 'view' actions

				'actions'=>array('index','view','GrantAllRoles'),

				'users'=>array('*'),

			),

			

	}

Hmmm, I don’t think this is the problem, but CreateUrl is not a static method, you can’t call it like this.

You should use $this->createUrl(), or Yii::app()->createUrl()

Also, you may check your UserController accessRules

check the below code this may help you.


<?php echo CHtml::ajaxSubmitButton(Yii::t('job','Create Job'),CHtml::normalizeUrl(array('job/addnew','render'=>false)),array('success'=>'js: function(data) {

                        $("#Person_jid").append(data);

                        $("#jobDialog").dialog("close");

                    }'),array('id'=>'closeJobDialog')); ?>

Solved.thanks a lot guys