title: how to make a select option using ajax call .on retrieval it produces an array
body: <p>how to add the resultant array data as a select option to get dropdown?   </p>
  
  <pre><code> &lt;html&gt;
      &lt;script&gt;
      $(document).ready(function() {
          $("#class_name").change(function(){
              var class_id=$("#class_name").val();
              //alert(""+class_id);
              $.ajax({
                  url: "../masters/getsection.php", 
                  type: "POST",            
                  data:"class_id="+class_id,
  
                   success: function(data){
                      alert(data);
  
                  }
  
  
  
      });
          });
  });
  
  &lt;/script&gt;
  &lt;body&gt;
  &lt;div class="form-group"&gt;
              &lt;div class="col-sm-9"&gt;
              &lt;select name="class_name" class="form-control" id="class_name"&gt;
              &lt;?php
              sizeof($StudentArray);
              for($i=0;$i&lt;sizeof($StudentArray);$i++){
              echo "&lt;option value='".$StudentArray[$i]     ['classId']."'&gt;".$StudentArray[$i]['name']."&lt;/option&gt;";
              }
              ?&gt;
              &lt;/select&gt;
          &lt;/div&gt;
      &lt;div class="form-group"&gt;
                  &lt;div class="col-sm-9"&gt;
                  &lt;select  class="form-control" name="section_name" id="section_name" &gt;
                  &lt;option value=array['sec_id']&gt;.array['sec_name']&lt;/option&gt;//how to give the array value here?
  
              &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>success of data array gives result as</p>
  
  <pre><code> array([0]=&gt;array(['sec_id']=&gt;1['name']=&gt;A)
   [1]=&gt;array(['sec_id']=&gt;2['name']=&gt;B)
   )
  </code></pre>
  
  <p>my question is how to print this array value in the secont ?
  my getsection.php is </p>
  
  <pre><code>&lt;?php
  include '../common/inc.common.php';
  $class_id=$_POST['class_id'];
  $tableName1 = "section";
  $fields1="sec_id,sec_name";
  $conditions1="where stat='A' and class_id='$class_id'";
   $SectionArray = $Cobj-&gt;getCustomData($tableName1,$fields1, $conditions1);
  print_r($SectionArray);
  ?&gt;
  </code></pre>