This is my code. I try reload table cgridview with ajax. I send data to action create and show table in _table.php.
in index.php I remove gridview and add this code
<?php $this->renderPartial('_rpsTable', array(
'provider' => $dataProvider,
)) ?>
in firebug in response i see html table code. but I don’t know why I can’t get it in index.php. I add alert in done() but it not work.
public function actionIndex()
{
$model=new Model;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$dataProvider=new CActiveDataProvider('Model');
$this->render('index',array(
'dataProvider'=>$dataProvider,
'model'=>$model,
));
}
public function actionCreate()
{
if ($_POST['Model']) {
$model = new Model;
$model->attributes = $_POST['Model'];
if ($model->save()) {
$dataProvider = new CActiveDataProvider('Model');
$this->renderPartial('_table', array(
'provider' => $dataProvider,
));
Yii::app()->end();
}
else
echo 'error';
Yii::app()->end();
}
}
$.ajax({
'url': window.location.href+'/create',
'type': 'post',
'cache': false,
'data': {'Model[one]': one, 'Model[two]': two},
'dataType': 'json',
})
.done(function (data) {
alert(55555555);
});