title: Passing user input data from view to controller via AJAX in Laravel 5.1
body: <p>I want to send drop-down list data from view to controller via AJAX as a form variable using post method.</p>
  
  <p>I am able to send the drop-down list data from view to controller using get method and using route parameters.</p>
  
  <p>Here is my view code snippet:</p>
  
  <pre><code>function drawChart(frmyear, toyear) 
  {
  
      console.log(frmyear);
      console.log(toyear);
  
  
          var jsonData = $.ajax({
          url: "get_salesthree/"+ frmyear + "/"+ toyear +"/",
          dataType: 'json',
          async: false
                      }).responseText;
  
          console.log(jsonData);
  </code></pre>
  
  <p>Route code snippet:</p>
  
  <pre><code>    Route::get('get_salesthree/{frmyear}/{toyear}', array('uses'=&gt;'Analytics\DashboardController@get_salesthree'));
  </code></pre>
  
  <p>For security reasons I don't want to pass user input data using route parameters. Also I have multiple user input parameters which needs to send to controller hence above method is not feasible as well. Hence any other alternative solution available in this case?</p>
  
  <p>Controller code snippet:</p>
  
  <pre><code>public function get_salesthree($frmyear, $toyear)
  {   
  
       return \Response::json(Salethree::get_formatted_salesthree($frmyear, $toyear ));
  
  }
  </code></pre>
  
  <p>Dropdownlist code snippet:</p>
  
  <pre><code>&lt;label&gt;From Date&lt;/label&gt;
                      &lt;select id="ddlfrmyear" name="frmyear" onchange="check(this);"&gt;
                      &lt;option value="-1"&gt;Select Date &lt;/option&gt;
                          @foreach ($date_lists as $date_list)
                      &lt;option value="{{ $date_list}}"&gt;{{ $date_list}}&lt;/option&gt;
                          @endforeach
                      &lt;/select&gt;
  </code></pre>
  
  <p>JavaScript check function:</p>
  
  <pre><code>function check(sel) 
  {
     document.getElementById('ddltoyear').disabled = !sel.selectedIndex;
     var frmyear =  document.getElementById('ddlfrmyear').value;
  
     var toyear =  document.getElementById('ddltoyear').value;
  
     console.log(frmyear);    
     console.log(toyear);
      if (toyear != '-1')
      {
          drawChart(frmyear, toyear);
          //drawChart();      
     }
  }
  </code></pre>
  
  <p>Now I am getting check function is not defined after changing ajax call as suggested. I am wondering what it the relation between on-select event of drop-down list and AJAX route? </p>