AJAX
$( document ).ready(function(){
$('#clinics li a').click(checkService($(this).attr('value')));
});
function checkService(id_clinic){
$.ajax({
url: host + "appointments/checkService",
async: true,
type: 'POST',
dataType: 'json',
data: {id_clinic : id_clinic},
success: function(data){
$('#result').html(data);
}
});
};
Запрос к базе
public function listServiceOfClinics($id){
if(!$id){
return false;
}
return $this->db->select('t_services.s_id,t_services.s_name')->from('t_services')->join('t_listserviceofclinics','t_services.s_id = t_listserviceofclinics.s_id_services')->where(['s_id_clinic'=>$id])->get()->result_array();
}
Контроллер
public function checkService(){
$id_services = $this->model_appointments->listServiceOfClinics($this->input->post('id_clinic'));
print json_encode($id_services);
}