I am working on a new project and it's on a nice framework which is CodeIgniter, but I got some problem when I want to use ajax (I am very bad with this). I want to get the value of a select on my controller but I don't know why (maybe because I am bad with ajax) I can't get the correct value. When I want to know what the ajax request send me it's show a boolean.
On the network app from Chrome I got the request who send the correct value which is "annee : the value of the select" but can't get it on my controller..
This is my ajax :
$('#annee').change(function(){
var annee = $('#annee').val();
console.log(annee);
$.ajax({
url: "admin",
type: 'post',
data: {annee:annee},
})
});
This is my Model (cmip_model.php):
function getWhere($annee) {
$query = $this->db->get_where('cmip_surcharges_go', array('annee' =>
$annee));
return $query->result ();
}
This is my controller (CMIP.php):
public function admin()
{
$this->load->model('cmip_model');
$cmip_Obj = new cmip_model();
$surcharges = $cmip_Obj->getWhere($this->input->post('annee'));
$data = array();
$data['surcharges'] = $surcharges;
$data['page_title'] = " :: Admin";
$data['main_content'] = 'client/CMIP/admin';
$data['active'] = 'CMIP';
$this->load->view('_includes/template', $data);
}
And this is my view :
année: <select id="annee">
<option value="">--année--</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
</select>
<?php var_dump($this->input->post('annee'));
var_dump($surcharges);
?>
Actually I got this from my var dump :
B:\wamp\www\cotationtro\applications\frontoffice\views\client\CMIP\admin.php:380: boolean false