I would like to know how to make a request via ajax in real time, basically it is for popular a select of cities, but when I have to execute the code, the modal does not just open, follow the code to analyze. >
no controler
$id = $_POST;
$query = $this->db->query(" SELECT * FROM estados ")->result();
$query_cidades = $this->db->query(" SELECT * FROM cidades WHERE cidades.cod_estado = $id")->result();
$data = [
'revendedor' => Model\Revendedores::find($cod_revendedor),
"estados" => $query,
"cidades" => $query_cidades
];
$this->load->view('revendedores/_form', $data);
na view
$('.escolha').on('click', function(){
var id_box = $( this ).data('id-box');
$.ajax({
url: "sua url",
method: "POST",
dataType: "json",
data:{
id : id_box,
}
}).done(function( data ) {
$('.escolha').html(data.id);
});
});