title: Yii2 ajax validate and submit form
body: <p>I have very little AJAX's Information. That's why I asked my question here...</p>
  
  <p>in yii2 how can create and submit form with ajax validation?</p>
  
  <p>So I searched but could not find the right solution...</p>
  
  <p>for example: (according to the official training site)</p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin([
              'id' =&gt; $model-&gt;formName(),
              'enableAjaxValidation' =&gt; true,
  ]); ?&gt;
  
  
  &lt;?= $form-&gt;field($model, 'title')-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
  
  &lt;?= $form-&gt;field($model, 'extra_txt')-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
  
  &lt;div class="form-group"&gt;
      &lt;?= Html::submitButton($model-&gt;isNewRecord ? 'Create' : 'Update', ['class' =&gt; $model-&gt;isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?&gt;
  &lt;/div&gt;
  
  &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  
  <p>and in controller:</p>
  
  <pre><code>    if (Yii::$app-&gt;request-&gt;isAjax &amp;&amp; $model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
          Yii::$app-&gt;response-&gt;format = 'json';
          return ActiveForm::validate($model);
      } else {
          return $this-&gt;render('create', [
              'model' =&gt; $model,
          ]);
      }
  </code></pre>
  
  <p>My problems:</p>
  
  <p>1- ajax validation</p>
  
  <p>2- submit form with ajax</p>