How To Use Ajax In Cgridview Button?

Hi i am using ajax button in CgridView.I need to add record of a single student at a time. Here is its view

When button is clicked the two fields namely "Obtained Marks" and "remarks" are sent via ajax request to action. The specific record is updated in the database.

Code is like this


<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(

	'id'=>'subject-result-form',

	'enableAjaxValidation'=>false,

    'action' => Yii::app()->createUrl('SubjectResult/addResult'),

    'id'=>'customForm',

    

)); ?>


<?php $gridColumns=array(

    array(

         

        'header' => 'Student',

        'value'=>'$data->student->first_name',

        'htmlOptions' => array('style' => 'text-align:center;'),

        'id'=>'$data->id'

    ),

    array(

        'header' => 'Marks Obtained',

        'type'=>'raw',

        'value'=>'CHtml::textField("",$data->obtained_marks,array("style"=>"width:200px;","id"=>"obtained_marks_"."$data->id"))',

        'htmlOptions' => array('style' => 'text-align:center;')

    ),

    array(

        'header' => 'Remarks',

         'type'=>'raw',

        'value'=>'CHtml::textField("",$data->remarks,array("style"=>"width:200px;","id"=>"remarks_"."$data->id"))',

        'htmlOptions' => array('style' => 'text-align:center;','id'=>'$data->id')

    ),

    array(

        'header'=>'',

        'type'=>'raw',

        'value'=>'CHtml::ajaxButton("Add","addResult",array("update"=>"#SubjectResult_$data->id","type"=>"POST","data"=>array("id"=>"$data->id","marks"=>"js:select($data->id)")))'

    ),

    );

$this->widget('bootstrap.widgets.TbGroupGridView', array(

	'filter'=>$person,

	'type'=>'striped bordered',

	'dataProvider' => $dataProvider,

	'template' => "{items}",

	//'extraRowColumns'=> array('firstLetter'),

	//'extraRowExpression' =>  '"<b style=\"font-size: 3em; color: #333;\">".substr($data->id, 0, 1)."</b>"',

	//'extraRowHtmlOptions' => array('row'=>'subject_'.$data->id),

	'columns' => $gridColumns,

        // 'rowHtmlOptionsExpression' => array('row'=>'subject_'.$data->id),

	//'mergeColumns' => array('language')

)); ?>

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

<script type="text/javascript">

    function select($id)

    {

        var temp=$('#obtained_marks_'.concat($id)).attr('value');

        alert(temp);

        return(temp);

    }

</script>

In ajax button i need to send data. Now it is sending data but i am confused about this that whether my way of doing this is correct or not. I also need to validate data but dont want to write too much javascript code on page.i also need to disable the row whose data is sent so no further data could be sent. I need community`s help about that is there any efficient way of doing this task? I am doing this using POST.