i had some faults in my code that is why i was not getting the results.
first i was using
return $.get("<?php echo base_url('get_testname'); ?>", { query: query }, function (data) {
which should be $.post() so i changed to
return $.post("<?php echo base_url('get_testname'); ?>", { query: query }, function (data) {
secondly i was using check in my controller method instead of query so i changed the check to query
public function get_doctor()
{
$query = $this->input->post('query');
$data = $this->customers->get_doctor($query);
echo json_encode( $data);
}