title: why ajax jquery didnt work if get value(where clause) from input
body: <p>I have data to be displayed in the 'Modal'. The data was obtained from the query I tried in phpmyadmin and it worked. I also tried it with a query with the time statement 'CURRENT_DATE' and it worked too. But when I tried it with time information with manual input (months and years manually inputted) the query didn't work.</p>
  
  <p>this my query first and its stil work</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(".monitor").click(function(){
  
          $("#list-format").html("");
          let nama_puskesmas = $(this).data('nama');
          let id_puskesmas = $(this).data('id');
  
  
          $.ajax({
              url     : 'get_data',
              method  : 'post',
              dataType: 'json',
              data    : {id_puskesmas:id_puskesmas},
              success : function(response){
  
                  $.each(response, function(i, obj){
                      $("#list-format").append("&lt;li&gt;"+obj.format+"&lt;/li&gt;");
                  });
  
                  $("#title-modal").html(nama_puskesmas);
                  $("#exampleModalCenter").modal('show');
  
  
  
              }
  
  
  
          })      
  
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>this my controller (work)</p>
  
  <pre><code>public function get_data(){
      $id_puskesmas = $this-&gt;input-&gt;post('id_puskesmas',TRUE);
  
      $data = $this-&gt;app_model-&gt;ambil200($id_puskesmas);
      echo json_encode($data);
  }
  </code></pre>
  
  <p>this model (work)</p>
  
  <pre><code>    function ambil200($id){
  
          $query = $this-&gt;db-&gt;query
  ("select tb_format.format from tb_format where tb_format.id not in
  (select penyakit.format from penyakit where penyakit.id_puskesmas =$id 
   group by penyakit.format having MAX(MONTH(penyakit.waktu_upload)) = MONTH(CURRENT_DATE))");
  
  
          return $query-&gt;result();
  
  
      }
  </code></pre>
  
  <p>and now i want to change query like this . 
  the ajax jquery code is the same as above but, the controller and the model are different</p>
  
  <p>controller (didnt work) ( i changed get_data , i changed it too into ajax code)</p>
  
  <pre><code>public function get_data_status(){
      $id_puskesmas = $this-&gt;input-&gt;post('id_puskesmas',TRUE);
      $year = $this-&gt;input-&gt;post('tahun');
      $month = $this-&gt;input-&gt;post('bulan');
      $data = $this-&gt;app_model-&gt;post_data($id_puskesmas,$year,$month);
      //die(print_r($data));
      echo json_encode($data);
  }
  </code></pre>
  
  <p>model(new query didnt work) . the diferent is input $month and $year.</p>
  
  <pre><code>public function post_data($id,$year=null,$month=null){
      if($year == null){
          $year = date("Y");
          }
          if($month == null){
          $month = date("m");
          }
  
  
      $query = $this-&gt;db-&gt;query("select tb_format.format 
          from tb_format 
          where tb_format.id not in
          (select penyakit.format from penyakit where penyakit.id_puskesmas =$id
          AND YEAR(waktu_upload) = '$year' AND MONTH(waktu_upload) = '$month'  
          group by penyakit.format)
          ");
  
      //die(print_r($query));
      return $query-&gt;result();
  }
  </code></pre>
  
  <p>this data not showed , can someone help me ?</p>