AjaxButton trouble

So I have been trying to use an ajax button to rate something up and down but I can’t quite get the syntax right. This is what I have so far that I have gotten out of a tutorial:


<?php

Chtml::ajaxButton (

        'Up',   //Label on the button

        'array("rate")',    // this the url of the proccess file... or use call the action function of the current controller.

       	'type' => 'post'  // method type Post or GET

        'data' =>array($model-id, Yii::app()->user->id, "1"),  // Data you want to send to controller.. must be in array

        'success' => 'function(data) { Thank you }',

);

?>

I basically want to process my form with the rate action in my current controller and than print out thank you once it has been processed. What am I doing wrong here?

Ok so I got it to work to a point now, but I can’t access the variables am sending to my controller. Here is my new code:




<?php

	echo CHtml::ajaxButton(

	    'Submit request',

	    array('videos/rating'),

	    array(

	        'update'=>'#req_res02',

	    ),

		array('test' => $model->id)

	);

	?>

And my controller:




	public function actionRating() {

	    echo CHtml::encode(print_r($_POST, true));

	}

for ajax working you 'd better use the firebug panel to see what 's really happened !

and make sure you have the permission to access the actionRating , check the access rules settings of your controller . :P

Well I have made sure that access rules are right but for some reason it is still not accessing the controller action :( Here is my new code:


<?php

	echo CHtml::ajaxButton(

	    'Submit request',

	    array('videos/rating'),

	    array('data'=>array('test'=>$model->id)),

            array('update'=>'#req_res02')

	);

	?>




	public function actionRating() {

	   if(Yii::app()->request->isAjaxRequest){

                echo "In the action";

        }

	}

Does any one know why this is still not working?

Try $this->createUrl(‘videos/rating’);