title: Codeigniter, Ajax: Pass the variable type date from view in controller
body: <p>I would like to send variables by post method from view to controller using Ajax. My code doesn't work. Can someone help me?</p>
  
  <p>My View: variables change with daterangepicker</p>
  
  <pre><code>var v_start_date = moment().subtract(7, 'days').format("YYYY-MM-DD HH:mm");
  var v_end_date = moment().format("YYYY-MM-DD HH:mm");
  ...
  //window.location.replace("&lt;?php echo site_url('consum/ajax_excel');?&gt;" + "/" + v_start_date + "/" + v_end_date);
  $.ajax({
      url: "&lt;?php echo site_url('consum/ajax_excel')?&gt;",
      type: "POST",
      dataType : "JSON",
      data:  {
         start_date: v_start_date,
         end_date: v_end_date
      },
      success:function(data) {
      },
      error : function(data) {
      }
  });
  
  ...
  </code></pre>
  
  <p>My Controller: </p>
  
  <pre><code>public function ajax_excel() {
      //$start_date = $this-&gt;uri-&gt;segment(5);
      //$end_date = $this-&gt;uri-&gt;segment(6);
      $start_date = $this-&gt;input-&gt;post('start_date');
      $end_date = $this-&gt;input-&gt;post('end_date');
      $this-&gt;load-&gt;library('excel');
      $mobiledata = $this-&gt;consum-&gt;excel_list($start_date,$end_date);
      $objPHPExcel = new PHPExcel();
  
  ...
  </code></pre>
  
  <p>My Model:</p>
  
  <pre><code>public function excel_list($start_date,$end_date){
      $this-&gt;db-&gt;select(array('date','consumator','produs','pret','cantitate','total','stare','utilizator'));
      $this-&gt;db-&gt;from('consum as m');
      if($start_date !="") if ($end_date !="") {
          $this-&gt;db-&gt;where('date &gt;=', $start_date);
          $this-&gt;db-&gt;where('date &lt;=', $end_date);
      }
      $this-&gt;db-&gt;order_by("date", "desc");
      $query = $this-&gt;db-&gt;get();
      return $query-&gt;result_array();
  }
  </code></pre>
  
  <p>Thanks a lot!</p>