title: How to display records based on selected year from dropdown dynamically without any submit button
body: <p>I am working on PHP code-igniter.</p>
  
  <p>My view code goes like below:</p>
  
  <pre><code>&lt;form method="post" action=""&gt;  
      &lt;div class="col-md-4 col-sm-4 "&gt;
          &lt;div class="form-group"&gt;                            
              &lt;label class="h5" for="Mode"&gt;&lt;b&gt;See year wise commitments&lt;/b&gt;&lt;/label&gt;
              &lt;select class="form-control" name="Year" id="Year"  onchange="this.form.submit()"&gt;
                  &lt;option value=""&gt;Select Year&lt;/option&gt;
                  &lt;option value="2015"&gt;2015&lt;/option&gt;
                  &lt;option value="2016"&gt;2016&lt;/option&gt;
                  &lt;option value="2017"&gt;2017&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Just by selecting any year from dropdown, I have to pass the selected year to my controller and inturn to model and get the query results based on the selected year.</p>
  
  <p>In my controller I am receiving the posted value like:</p>
  
  <pre><code>$selectedYear = $this-&gt;input-&gt;post('Year');
  </code></pre>
  
  <p>And before selecting any dropdown value the records in my view has to be of Current year. </p>
  
  <p>My ajax code is</p>
  
  <pre><code>$( "#year" ).change(function() {
      year = $(this).val();
      $.ajax({
            url : "controllerfilename/controllername",
            data : {"year": year},
            type : "post",
            success: function(data){
               console.log(data);
            }
     });
  </code></pre>
  
  <p>});</p>