title: Yii2 Pjax Delete not working
body: <p>I am trying to make an Ajax GridView using Pjax with delete button. Deleting goes with no Ajax. I am new to Yii2 so any help would be appreciated. Thank you.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php Pjax::begin(['id' =&gt; 'countries']) ?&gt;
  &lt;?= GridView::widget([
      'dataProvider' =&gt; $dataProvider,
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
  
          'id',
          'title',
  
  
          ['class' =&gt; 'yii\grid\ActionColumn',
              'buttons' =&gt; [
                  'delete' =&gt; function ($url, $model, $key) {
                      return Html::a('&lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;', $url, [
                          'title' =&gt; Yii::t('yii', 'Delete'),
                          'data-confirm' =&gt; Yii::t('yii', 'Are you sure you want to delete this item?'),
                          'data-method' =&gt; 'post',
                      ]);
                  },
              ]
          ],
      ],
  ]); ?&gt;
  &lt;?php Pjax::end() ?&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function actionDelete($id)
  {   
      $model = new Category();
      $this-&gt;findModel($id)-&gt;delete();
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; Category::find(),
      ]);
      return $this-&gt;render('index', [
          'dataProvider' =&gt; $dataProvider,
          'model' =&gt; $model,
      ]);
  }
  </code></pre>
  
  <p>This is public function actionIndex() in the <strong>Controller</strong></p>
  
  <pre><code>public function actionIndex()
  {
      $model = new Category();
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; Category::find(),
      ]);
  
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save())
      {
          $model = new Category();
      }
      return $this-&gt;render('index', [
          'dataProvider' =&gt; $dataProvider,
          'model' =&gt; $model,
      ]);
  }
  </code></pre>