Custom Update Cgridview

Hi

I want to enforce updates a CGridView by new data


 function refreshGrid() {

  $.fn.yiiGridView.update("my-grid", {

         type: "POST",

         url: "' . $myUrlUpdate . '",

         data: {},

         });

  }

the update Action (Yii controller/action) outputs only the my-grid content (including the <div id="my-grid">…)

I check manually that the controller/action outputs the gridview but the CCridview not updated

I tried also


 $.ajax({

         type: 'POST',

         url: "'. $urlUpdate; '",

         success: function(data) { //alert(data);

         $('#my-grid').yiiGridView('update', {data: data});

         }

         });

The data returned back to the client (alert(data)) but cgridview still not update

Whats wrong ?

Thanks

All above code is in registerscript, so double quotes are ok

Opps… actually the ‘my-grid’ is ‘my_grid’

finally the first way it works.

About the second way works but refreshed twice,

The first time by my ajax and the second due to internal request that called by

$(’#my-grid’).yiiGridView(‘update’, {data: data});

finally in this case the data refreshed as it was before ajax request,

So, how to prevent this ?