title: Yii2- unable to redirect from one view to another with dataprovider
body: <p>I have a view in which I have a <code>a</code> tag button. On the click of the button a an <code>ajax</code> request is sent to the given <code>action view controller</code> and in that <code>action view</code> some values are saved in the database. After that I am redirecting the view to another view. </p>
  
  <p><strong>What I have done?</strong></p>
  
  <p><strong>My View</strong></p>
  
  <pre><code>&lt;a href="&lt;?= URL::toRoute(['ogpheader/viewsetpdf', 'id'=&gt;$model-&gt;id])?&gt;"  name="redirect" class="btn btn-primary" id="myid"&gt;Set PDF&lt;/a&gt;
  //this is the a tag button
  </code></pre>
  
  <p><strong>Ajax call in same view</strong></p>
  
  <pre><code>&lt;?php
  $url = Url::toRoute(['/ogpheader/viewsetpdf','id'=&gt;$model-&gt;id]);
  $script = &lt;&lt;&lt; JS
  $(document).ready(function () {      
  
  $('#myid').on('click',function(e) {
  e.preventDefault();    
   var strValue = "";        
      $('input[name="selection[]"]:checked').each(function() {
  
      if(strValue!="")
          {
          strValue = strValue + " , " + this.value;
  
          }
      else 
         strValue = this.value;     
  
  });
      //alert(strValue);
  $.ajax({
       url: '$url',
       type: 'POST',
       dataType: 'json',
       data: {data:strValue},         
       success: function(data) {
          alert(data);
        },
       }); 
      }) 
    });
    JS;
    $this-&gt;registerJs($script, static::POS_END);
    ?&gt;
  </code></pre>
  
  <p><strong>My action Controller</strong>              </p>
  
  <pre><code>if(Yii::$app-&gt;request-&gt;isAjax &amp;&amp; Yii::$app-&gt;request-&gt;post())
      {
          $data = explode(',',$_POST['data']);
  
          foreach($data as $value)
          {
              $m = new Ogpdetail;
              $m -&gt; load(Yii::$app-&gt;request-&gt;post());
              $m-&gt;ogp_id = $ogp_id;
              $m-&gt;created_at = date('Y-m-d h:i:s');
              $m-&gt;meter_id = $value;
              $m-&gt;meter_serial = \common\models\Meters::idTomsn($value);
  
              if($m-&gt;save())
              {
                  $model-&gt;status = Ogpheader::$status_titles[1];
                  $model-&gt;update();
                  //echo "All data is saved";
                  //exit();
              }
              else{
                  $this-&gt;renderAjax('viewcreated');
              }
          }
  
          //print_r($data);
      }
      else{
          $this-&gt;renderAjax('viewcreated');
      }
  $query = "SELECT DISTINCT  ogpd.`meter_serial` AS 'Meter_Serial_Number', IFNULL(ogpd.`remarks`,'') AS 'Remarks' FROM `ogp_detail` ogpd
                          INNER JOIN `ogp_header` ogph ON ogpd.`ogp_id` = ogph.`id`";
  
      $count = Yii::$app-&gt;db-&gt;createCommand("SELECT COUNT(DISTINCT ogpd.`meter_serial`) FROM `ogp_detail` ogpd
                           INNER JOIN `ogp_header` ogph ON ogpd.`ogp_id` = ogph.`id`")-&gt;queryScalar();
  
      $dataProvider = new SqlDataProvider([
          'sql' =&gt; $query,
          'totalCount' =&gt; $count,
          'pagination' =&gt; [
              'pageSize' =&gt; 5,
          ],
      ]);
  
      return $this-&gt;redirect('viewsetpdf',[
          'dataProvider' =&gt; $dataProvider,
          'model' =&gt; $this-&gt;findModel($id),
          'id' =&gt; $model-&gt;id
      ]);
  </code></pre>
  
  <p>When i click on my <code>Set PDF</code> button I am getting <code>Not Found (#404)</code>. While all the records are saved into my desired tables. </p>
  
  <p>Also the <code>URL</code> is <code>http://localhost:225/inventory-web/backend/web/ogpheader/viewcreated/viewsetpdf</code> but it should be <code>http://localhost:225/inventory-web/backend/web/ogpheader/viewsetpdf</code></p>
  
  <p>I don't know what is the problem and I am stuck to it. </p>
  
  <p>Any help would be highly appreciated.</p>