I need that when writing in an input of type text, if what I wrote corresponds to a value of the database, the result, which in this case would be the name of a student, is shown in another input of type text . I am entering the data in a modal, but when writing in the input, it does not show me the result (within the same modal). I leave the code in case you know that it is missing or that I should correct, I would appreciate it. I throw this Error:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: models / mCalendar.php
Line Number: 59
Backtrace:
File: C: \ xampp \ htdocs \ SAE \ application \ models \ mCalendar.php
Line: 59
Function: _error_handler File: C: \ xampp \ htdocs \ SAE \ application \ controllers \ cCalendar.php Line: 52
Function: search_student File: C: \ xampp \ htdocs \ SAE \ index.php Line: 315
Function: require_once Array
Line 59 is echo $ student;
Model (mCalendar)
public function buscar_estudiante($rut_estu){
$this->db->select('CONCAT(pnombre, " ",apellido_pa," ", apellido_ma) As estudiante');
$this->db->from('estudiantes');
$this->db->where('rut_estu',$rut_estu);
$estudiante = $this->db->get()->result();
echo $estudiante;
}
Controller (cCalendar)
public function buscar_estudiante(){
$rut_estu= $this->input->post('rut_estu');
$estudiante = $this->mCalendar->buscar_estudiante($rut_estu);
}
javascript within the View
$("#rut_estu").keyup(function(){
var parametros = {
"rut_estu" :$("#rut_estu").val(),
}
$.ajax({
data: parametros,
url: '<?php echo base_url();?>cCalendar/buscar_estudiante',
type: 'post',
beforeSend: function () {
$("#nombre_estu").val();
},
success: function (response) {
$("#nombre_estu").val(response);
}
});
});