title: How to Reload a Bootstrap Modal popup in Yii2?
body: <p>I have a Modal popup, after the user submit the data, I want to show the results on the same popup. How do I reload that modal view? Thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/3AD2I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3AD2I.png" alt="popup view"></a></p>
  
  <p>This is the popup view:</p>
  
  <pre><code>&lt;div class="site-popup"&gt;
      &lt;h1&gt;&lt;?= Html::encode($this-&gt;title) ?&gt;&lt;/h1&gt;
  
      &lt;div class="row"&gt;
          &lt;div class="col-lg-5"&gt;
              &lt;?php $form = ActiveForm::begin(['id' =&gt; 'popup-form']); ?&gt;
                  &lt;?= $form-&gt;field($model, 'pattern')-&gt;textArea(['rows' =&gt; 1]) ?&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;?= Html::submitButton('Submit', ['class' =&gt; 'btn btn-primary', 'name' =&gt; 'popup-button']) ?&gt;
                  &lt;/div&gt;
  
              &lt;?php ActiveForm::end(); ?&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  
   &lt;?php
      echo "&lt;pre&gt;";
      print_r($model-&gt;data); 
   ?&gt;
  </code></pre>
  
  <p>This is the view that calls to the above modal popup view:</p>
  
  <pre><code>&lt;p&gt;
      &lt;?= Html::button('Search', ['value' =&gt;Url::to('index.php?r=site/mypopup'),'class' =&gt;'btn btn-success', 'id'=&gt;'modalButton']) ?&gt;
   &lt;/p&gt;
          &lt;?php
              Modal::begin([
              'header'=&gt; '&lt;h4&gt;Search&lt;/h4&gt;',  
              'id' =&gt; 'modal',
              'size' =&gt; 'modal-lg',
              ]);
  
              echo "&lt;div id='modalContent'&gt;&lt;/div&gt;";
  
              Modal::end();
         ?&gt;
  </code></pre>
  
  <p>The js file:</p>
  
  <pre><code>$(function(){
      //get the click of the search button
      $('#modalButton').click(function(){
          $('#modal').modal('show')
              .find('#modalContent')
              .load($(this).attr('value'));
          }); 
  });
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function actionPopup()
  {
  
   $model = new PopupForm();
  
     if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;validate()) 
     {
        $model-&gt;insertPopup();
           return $this-&gt;renderAjax('mypopup', ['model' =&gt; $model]);
  
              } else {
                  return $this-&gt;renderAjax('mypopup', [
                      'model' =&gt; $model,
                  ]);
              } 
  }
  </code></pre>