How can i get value from select option using ajax and php
<p>I have 2 select box option, city and district. I use ajax go get district name when I choose on the city. For this process I have succeed but when I click submit I get the error message Undefined index: district ,as this picture you can see
<a href="http://i.stack.imgur.com/kjU36.jpg" rel="nofollow">result image</a>.</p>

<p>Here is my ajax code:</p>

<pre><code> $(document).ready(function($) {
    $("#city").change(function() {
        var search_id = $(this).val();
        $.ajax({
            url: "search.php",
            method: "post",
            data: {search_id:search_id},
            success: function(data){
                $("#district").html(data);
            }
        })
    });
});
</code></pre>

<p>Here is HTML code:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>   

 &lt;form action="" method="post"&gt;
    select city:
    &lt;select name="city" id="city"&gt;
     &lt;option value="1"&gt;Phnom Penh&lt;/option&gt;
     &lt;option value="2"&gt;Kampong Soam&lt;/option&gt;
      &lt;option value="3"&gt;Siem Reap&lt;/option&gt;
    &lt;/select&gt;

    select district:
    &lt;select name="distrcit" name="district" id="district"&gt;
     &lt;option&gt;Select District&lt;/option&gt;
    &lt;/select&gt;

    &lt;input type="submit" name="submit"&gt;
    &lt;/form&gt;</code></pre>
</div>
</div>
</p>

<p>Here is PHP code:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php 
if(isset($_POST['submit'])){
 echo $_POST['city'];
 echo $_POST['district'];
}

 ?&gt;

//ajax request
&lt;?php 
if(isset($_POST['search_id'])){
 $search_id = $database-&gt;escape_string($_POST['search_id']);

 if(!empty($search_id)){
  // $output = array();
  $sql = "SELECT * FROM district WHERE ref_id = '$search_id'";
  $districts = District::find_this_query($sql);
  foreach($districts as $district){
   // echo $district-&gt;id;
   // echo $district-&gt;district_name;
   $output .= "&lt;option value='{$district-&gt;id}'&gt;{$district-&gt;district_name}&lt;/option&gt;";
  }

  echo $output;
 }
 
 }
?&gt;</code></pre>
</div>
</div>
</p>