title: how to display jquery/ajax data into select field?
body: <p>code:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
        $(".field").change(function(){
          field = $(".field").val();
          $.ajax({
            type:"POST",
            data:{"field":field},
            url:"potential-courses.php",
            success:function(data){
              $(".course").val(data);              
            }
          });
        });
      });
    &lt;/script&gt;
  </code></pre>
  
  <p>potential-courses.php</p>
  
  <pre><code>&lt;?php
      include("conn.php");
      $field = $_POST['field'];
      $sql = "select * from course_master where field = '$field' order by course_full_name";
      $result = mysqli_query($link,$sql);
      while ($row = mysqli_fetch_array($result)) 
      {
          echo "&lt;option value=".$row['course_short_name']."&gt;".$row['course_full_name']."&lt;/option&gt;";
      }
  ?&gt;
  </code></pre>
  
  <p>html code:</p>
  
  <pre><code>&lt;select  name='field' class='field' id="field"&gt;
      &lt;option value=""&gt;Select Field&lt;/option&gt; 
      &lt;option value='engineering'&gt;Engineering&lt;/option&gt;  
      &lt;option value='law'&gt;LAW&lt;/option&gt;  
      &lt;option value='medical'&gt;Medical&lt;/option&gt;  
      &lt;option value='management'&gt;Management&lt;/option&gt;  
      &lt;option value='pharmacy'&gt;Pharmacy&lt;/option&gt;
      &lt;option value='hotel management'&gt;Hotel Management&lt;/option&gt;
      &lt;option value='mass communication'&gt;Mass Communication&lt;/option&gt;
      &lt;option value='agriculture'&gt;Agriculture&lt;/option&gt;
      &lt;option value='architecture'&gt;Architecture&lt;/option&gt;
      &lt;option value='education'&gt;Education&lt;/option&gt;
      &lt;option value='paramedical'&gt;Paramedical&lt;/option&gt;
      &lt;option value='design'&gt;Design&lt;/option&gt;
      &lt;option value='commerce'&gt;Commerce&lt;/option&gt;
      &lt;option value='film/tV/media'&gt;Film /TV/ Media&lt;/option&gt;
    &lt;/select&gt;
  
    &lt;select name="course" class="course"&gt;
      &lt;option value=""&gt;Select Courses&lt;/option&gt;
    &lt;/select&gt;
  </code></pre>
  
  <p>In this code I have two dropdown list i.e </p>
  
  <pre><code>&lt;select  name='field' class='field' id="field"&gt;
  </code></pre>
  
  <p>and another is </p>
  
  <pre><code>&lt;select name="course" class="course"&gt;
  </code></pre>
  
  <p>when I change value from "name=field" it display nothing in "name=course". where I am doing wrong please help me.</p>
  
  <p>Thank You  </p>