Yii';默认的ajax不起作用

Yii';默认的ajax不起作用,ajax,yii,Ajax,Yii,在我的Yii应用程序中,Yii的默认Ajax不起作用。默认的Ajax验证也不起作用。这是安装问题还是其他问题。如何启用Yii的默认Ajax。 在我的控制器中 public function actionCreate() { $model = new Company; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model);

在我的Yii应用程序中,Yii的默认Ajax不起作用。默认的Ajax验证也不起作用。这是安装问题还是其他问题。如何启用Yii的默认Ajax。 在我的控制器中

 public function actionCreate() {
    $model = new Company;

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

    if (isset($_POST['Company'])) {
        $company = Company::model()->findAll();
        if (count($company) === 0) {
            $model->attributes = $_POST['Company'];
            $uploadedFile = CUploadedFile::getInstance($model, 'logo');
            if (isset($uploadedFile)) {
                $fileName = date('Ymdhis') . '_' . $uploadedFile->name;  // $timestamp + file name
                $model->logo = $fileName;
            }
            if ($model->validate()) {
                if ($model->save()) {
                    if (isset($uploadedFile)) {
                        $uploadedFile->saveAs(Yii::app()->basePath . '/../banner/' . $fileName);
                    }
                    $this->redirect(array('create'));
                }
            }
        } else {
            Yii::app()->user->setFlash('error', 'Company details is already exists.');
        }
    }

    $this->render('create', array(
        'model' => $model,
    ));
}
在查看页面中

  <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'company-form',
                    'enableClientValidation' => true,
                    'clientOptions' => array(
                        'validateOnChange' => true,
                        'validateOnSubmit' => true,
                    ),
                    // Please note: When you enable ajax validation, make sure the corresponding
                    // controller action is handling ajax validation correctly.
                    // There is a call to performAjaxValidation() commented in generated controller code.
                    // See class documentation of CActiveForm for details on this.
                    'enableAjaxValidation' => true,
                    'htmlOptions' => array('enctype' => 'multipart/form-data'),
                ));
                ?>

 <div class="form-group">
                    <?php echo $form->label($model, 'company_name', array('class' => 'req')); ?>
                    <?php echo $form->textField($model, 'company_name', array('class' => 'form-control')); ?>
                    <?php echo $form->error($model, 'company_name', array('class' => 'school_val_error')); ?>
                </div>

请帮帮我


谢谢

Yii没有默认的
AJAX
。这是一种基于
JavaScript
语言的技术。默认情况下,Yii包含一个
jQuery
库,该库提供了一些使用
AJAX
轻松操作的方法。如果要在页面上使用它,应添加以下字符串:

Yii::app()->clientScript->registerCoreScript('jquery');

您可以使用此代码将此字符串添加到主布局中,例如添加到/views/layouts/main.php`

的顶部,得到类似“CClientScript及其行为没有名为“registerCore”的方法或闭包”的错误。@Arya请更新您的问题并提供控制器,模型和查看代码。打开浏览器控制台,在填写表单时检查AJAX请求是否发送到服务器。是的,我检查了,但没有将AJAX请求发送到服务器。@Arya尝试删除
'enableClientValidation'=>true,
是否会阻止AJAX验证