title: In auto populate i have two dropdown related with each other
body: <p>In auto populate i have two drop down..one value is category fetched from database and another i show the subcategory of selected category. i use on change option to get subcategory. </p>
  
  <p>On editing on change not working i think because category is not changed.. How i get the sub category value without changing the category but use previous code event on change.</p>
  
  <pre><code>$(document).ready(function(){
      $('#category').on('change',function(){
          var mainID = $(this).val();
          if(mainID){
              $.ajax({
                  type:'POST',
                  url:'functions/ajaxlocation.php',
                  data:'cat_id='+mainID,
                  success:function(html){
                     $('#location').html(html);
                  }
              }); 
          }else{
              $('#location').html('&lt;option value=""&gt;Select Category first&lt;/option&gt;');
          }
  })
  </code></pre>