title: Yii2 : Sending data to same page not working properly
body: <p>I'm using Yii2-advanced-app. I want to send the value of my selected dropdown to a php code(which shows list with checkboxes) on same page. Please see the following image for reference (That's how I want actually)-</p>
  
  <p><a href="https://i.stack.imgur.com/1TDyU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1TDyU.png" alt="Please see this image for reference"></a></p>
  
  <p>But, after selecting some element from dropdown list, I'm getting the result, but with whole html page in that specific portion. Here is the Snap for reference -</p>
  
  <p><a href="https://i.stack.imgur.com/a6vF5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a6vF5.png" alt="Here is the Snap for reference"></a></p>
  
  <p>I don't understand why I'm getting the whole page in response.</p>
  
  <p>I've wrote the following code for that -</p>
  
  <p><strong><em>Dropdown List</em></strong></p>
  
  <pre><code>&lt;?= $form-&gt;field($countries[0], 'id')-&gt;dropDownList(
      ArrayHelper::map($countries, 'phonecode', 'name'),
      [
      'prompt' =&gt; 'Select Country',
      'onchange' =&gt; '
      var id;
      jQuery.ajax({
          type: "POST",
          data: {
              "id": $(this).val(), 
          },
          // url: "",
          success: function(data){
              jQuery(".tobechanged").html(data);
              alert(data);
          }
      });'
      ])-&gt;label(false);
      ?&gt;
  </code></pre>
  
  <p><strong><em>And my respective div is</em></strong></p>
  
  <pre><code>&lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 tobechanged" style="max-height: 400px; background: white; overflow: auto;"&gt;
      &lt;ul class="list-unstyled" id="chkall"&gt;
          &lt;?php
          if(isset($contacts)) {
              $contacts = $contacts;
                              // print_r($contacts[0]['cust_country_code']);exit();
              foreach ($contacts as $contact) {
                  if(isset($_POST['id'])) {
                      if($contact['cust_country_code'] == $_POST['id']) {
                          echo '&lt;li&gt;
                          &lt;div class="checkbox" id="checkboxes"&gt;
                              &lt;label&gt;&lt;input type="checkbox" value="'.$contact['cust_id'].'" id="'.$contact['cust_id'].'"&gt;'.$contact['cust_fname'].' '.$contact['cust_lname'].'&lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/li&gt;';
                  }
              } else {
                  echo '&lt;li&gt;
                  &lt;div class="checkbox" id="checkboxes"&gt;
                      &lt;label&gt;&lt;input type="checkbox" value="'.$contact['cust_id'].'" id="'.$contact['cust_id'].'"&gt;'.$contact['cust_fname'].' '.$contact['cust_lname'].'&lt;/label&gt;
                  &lt;/div&gt;
              &lt;/li&gt;';
          }
      }
  }
  ?&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>It doesn't work even when we display 'Hello' instead of checkboxes code. i.e like this-</p>
  
  <pre><code>&lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 tobechanged" style="max-height: 400px; background: white; overflow: auto;"&gt;
      Hello
  &lt;/div&gt;
  </code></pre>
  
  <p>So, please help me to avoid unwanted html.</p>
  
  <p><strong><em>I'm getting the Response like this</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/MWR0I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MWR0I.png" alt="Response"></a></p>