title: Submit Ajax form on select change
body: <p>I need to submit form on selection change. There's form I have.</p>
  
  <pre><code>&lt;form id="form" name="form" method="post" action="modules/submit.php"&gt;
  &lt;select name='category' id='category' size='12' onChange='this.form.submit();'&gt;
  &lt;option value='1'&gt;One&lt;/option&gt;
  &lt;option value='2'&gt;Two&lt;/option&gt;
  &lt;option value='3'&gt;Three&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name='subcategory' id='subcategory' size='12'&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>$(document).ready(function(){
      $('#form').submit(function() {
          select();
          e.preventDefault();
      });
  
  });
  
  
  function select()
  {
      error(0);
  
      $.ajax({
          type: "POST",
          url: "modules/submit.php",
          data: $('#form').serialize(),
          dataType: "json",
          success: function(msg){
              if(parseInt(msg.status)==1)
              {
                  window.location=msg.txt;
              }
              else if(parseInt(msg.status)==0)
              {
                  result(1,msg.txt);
              }
          }
      });
  
  }
  
  function result(act,txt)
  {
      if(txt) $('#subcategory').html(txt);
  }
  </code></pre>
  
  <p>submit.php:</p>
  
  <pre><code>if(isset($_POST['category'])){
  die(msg(0,"&lt;option value='0'&gt;Trololo&lt;/option&gt;"));
  }
  function msg($status,$txt)
  {
      return '{"status":'.$status.',"txt":"'.$txt.'"}';
  }
  </code></pre>
  
  <p>When i change selection form is being submitted and redirects to submit.php file.
  I need to get results for subcategory selection.</p>