hawkcraw 2013-06-19 15:01:51 3376次浏览 1条回复 0 0 0

我想使用yii自带的AJAX增删改查数据,我这样写的,好像验证后不执行后面了,怎么操作呢? 以下我的代码

public function actionCreate() {
        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);

        if ($this->_model && isset($_POST['NewsType'])) {
            $this->_model->attributes = $_POST['NewsType'];
            $this->performAjaxValidation($this->_model);
            $this->_model->save(); //[b]运行达不到这里[/b]
        }

        $this->render('_form', array(
            'model' => $this->_model
        ));
}
protected function performAjaxValidation($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-form') {
            echo CActiveForm::validate($model);
            Yii::app()->end(); //[b]这里已经停止运行[/b]
        }
}
您需要登录后才可以回复。登录 | 立即注册