title: How to save data using ajax request using CGridview in Yii
body: <p>When I submit button to update it does not save the data.Here in my view.php file ->
  `</p>
  
  <pre><code>'id'=&gt;'main-table-grid',
      'dataProvider'=&gt;$dataProvider,
      'columns'=&gt;array(
      array(
        'name'=&gt;'section_no',
        'type'=&gt;'raw',
        'value'=&gt;'CHtml::link($data-&gt;section_no)',
      ),
          'section_name',
          'sub_sec_no',
          'sub_sec_name',
          array(
        'name'=&gt;'text',
        'htmlOptions'=&gt;array('width'=&gt;'150'),
        'type'=&gt;'raw',
        'value' =&gt; 'CHtml::textArea("MainTable[text]",$data-&gt;text)',
      ),
          'review_response',
      array(
        'name'=&gt;'review_comment',
        'htmlOptions'=&gt;array('width'=&gt;'default'),
        'type'=&gt;'raw',
        'value' =&gt; 'CHtml::textArea("MainTable[review_comment]",$data-&gt;review_comment)',
      ),
      array(
        'class' =&gt; 'CButtonColumn',
        'template' =&gt; '{update}{view}{delete}',
        'buttons' =&gt; array(
          'update' =&gt; array(
            'options' =&gt; array('class' =&gt; 'save-ajax-button'),
            'url' =&gt; 'Yii::app()-&gt;controller-&gt;createUrl("saveModel", array("id"=&gt;$data-&gt;id))',
          ),
          'view',
          'delete',
        ),
      ),
      ),
  )); 
  ?&gt;
  &lt;script&gt;
     $('#main-table-grid a.save-ajax-button').live('click', function(e)
      {
          var row = $(this).parent().parent();
  
          var data = $('input', row).serializeObject();
  
          $.ajax({
              type: 'POST',
              data: data,
              url: jQuery(this).attr('href'),
              success: function(data, textStatus, jqXHR) {
                  console.log(text);
                  console.log(textStatus);
                  console.log(jqXHR);
              },
              error: function(textStatus, errorThrown) {
                  console.log(textStatus);
                  console.log(errorThrown);
              }
          });
          return false;
      });
  
  
      $.fn.serializeObject = function() {
          var o = {};
          var a = this.serializeArray();
          $.each(a, function() {
              if (o[this.name]) {
                  if (!o[this.name].push) {
                      o[this.name] = [o[this.name]];
                  }
                  o[this.name].push(this.value || '');
              } else {
                  o[this.name] = this.value || '';
              }
          });
          return o;
      };
  &lt;/script&gt;`
  </code></pre>
  
  <p>and in my controller I created an action method.The code is below-></p>
  
  <pre><code>public function actionSaveModel($id) {
      $model=$this-&gt;loadModel($id);
      $this-&gt;performAjaxValidation($model);
      if(isset($_POST['MainTable']))
          {
        $model = new MainTable();
        $model-&gt;attributes = $_POST['MainTable'];
        $model-&gt;save();
        $this-&gt;render('admin', array(
           'model' =&gt; $model,
        ));
          }
    }
  </code></pre>
  
  <p>I have set permission in my controller </p>
  
  <pre><code>    array('allow', // allow authenticated user to perform 'create' and 'update' actions
          'actions'=&gt;array('savemodel'),
          'users'=&gt;array('@'),
      ),
  </code></pre>
  
  <p>My problem is data is not saving in the table.Please let me know what is the issue here.
  Thank you.</p>