public function actionAdd($id) { $this->hasPrivilege(Acl::ACTION_VIEW); $child = new Child(); $model_class_name = $child->getClassName(); if (isset($_POST[$model_class_name])) { $child->attributes = $_POST[$model_class_name]; if (Yii::app()->request->isAjaxRequest) { Yii::app()->clientScript->scriptMap['jquery.js'] = false; echo CJSON::encode(array('status' => 'success', 'div' => "Child added successful")); //Close the dialog, reset the iframe and update the grid // echo CHtml::script("window.parent.$.fn.yiiGridView.update('#prevExp-grid');"); exit; } else { $this->redirect(array('../products/view', 'id' => $child->id)); } if (Yii::app()->request->isAjaxRequest) { Yii::app()->clientScript->scriptMap['jquery.js'] = false; echo CJSON::encode(array('status' => 'failure', 'div' => $this->renderPartial('_kid', array('child' => $child), true, true))); exit; } else { $this->render('_kid', array('child' => $child)); } } }