Answer the question
In order to leave comments, you need to log in
What is the error when sending an AJAX request to Codeigniter?
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);
}
Answer the question
In order to leave comments, you need to log in
So what is the error?
If the data comes from the server normally, then I think you have an error in the line:
you have json coming from the server, so data will contain a json object and you need to stuff it into a template first.
that's what the jamb was
$id_clinic = $this->input->post('id_clinic');
$id_services = $this->model_appointments->listServiceOfClinics($id_clinic);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question