title: populate dependent select box through ajax call in wordpress
body: <p>I want to poulate cities on behalf of selected state in select box. I am able to get the id of the selected state but unable to pass that state id to php function to get array of dependent cities. All this is in wordpress.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function()
  {
      function ajaxSubmit(){
  
          var stateId = $(this).val();
          // alert("SID"+stateId);
          jQuery.ajax({
          type:"POST",
          action:'getDist',
          data: stateId,
          url: "&lt;?php echo $adminUrl; ?&gt;"
      });
  }
      $('#billing_state').on("change", ajaxSubmit);
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Above ismy ajax call and below is my php function to which i want to pass state id..</p>
  
  <pre><code>    &lt;?php
  
          function getDist($id){
              global $wpdb;
              $dists  = $wpdb-&gt;get_results("select name from cities where state_id = ".$id);
              if($dists === FALSE):
                  echo $wpdb-&gt;error;
              else:
              foreach($dists as $dist){
                  echo"&lt;option value=".$dist-&gt;name."&gt;".$dist-&gt;name."&lt;/option&gt;";
              }
              endif;
          }
          add_action('wp_ajax_getDist', 'getDist');
      ?&gt;
  </code></pre>
  
  <p>after this i get nothing in cities select box..</p>