Hello, I would really like your help, because I do not work in the area, but I really like to learn, I started messing with codeigniter, I'm making a system for my work people, today everything is done in excel. The system is to manage associates, I have a table of enrollments and name of all employees; My problem is when I type the registration, I can not pull the person's name.
In my view I have:
<div class="col-xs-3 form-group">
<label>Matrícula</label>
<input style="text-transform:uppercase" class="form-control" type="text" id="matricula" name="matricula" placeholder="Nº matrícula"/>
</div>
<div class="col-xs-6 form-group">
<label for="nome">Nome</label>
<input style="text-transform:uppercase" class="form-control" type="text" id="nome" name="nome" placeholder="Digite a matricula" required/>
</div>
At the end of my view is the script with an AJAX request
$("input[name='matricula']").blur(function()
{
event.preventDefault();
/*
var matricula = $('#matricula').val();
*/
var nome = $("input[name='nome']");
nome.val('Carregando...');
$.ajax({
url: baseurl+ 'gesind/pesquisa_mat',
type: 'POST',
data: {
matricula: $('#matricula').val()
},
success: function(){
var nome = data['matricula'];
},
error: function(){
alert("erro");
}
});
});
In my controller I have
public function pesquisa_mat()
{
if (!$this->input->is_ajax_request())
{
exit('no valid req.');
}
$usr['matricula'] = $this->input->post('matricula');
$this->load->model("gesind_model");
$result = $this->gesind_model->pesquisa_matricula($usr);
if($result)
{
echo $result;
}
else
{
echo false;
}
}
and in the Model I have the following code
public function pesquisa_matricula($usr) //checks ajax requests
{
$this->db->where('matricula',$usr);
$query=$this->db->get("matriculas");
if($query->num_rows()>0)
{
return $query->result();
}
else
{
return false;
}
}
If anyone can help me, I am grateful.