I have the code below that does a check in my controller and it returns me a count of my request.
What I wanted is that in the success of my Jquery ajax I would capture this value to do some javascript conversations in my code.
I'm using the Laravel 5.2 framework.
Follow the code for my function in javascript and the function in the controller.
Controller:
public function verificaCPF($cpf){
$cpfvalidoeexistente;
if(BussinessRoles\SSV::validacaoCPF($cpf)){
$cpfvalidoeexistente = Aluno::where('cpf', $cpf)->count();
}
else{
$cpfvalidoeexistente = 0;
}
echo $cpfvalidoeexistente;
}
Function in javascript:
$.ajax({
type: "GET",
url: '/validacpf/'+cpf,
success: function (result) {
console.log(result);
msg('sucesso', 'O registro foi atualizado com sucesso!', '#resposta')
},
error: function () {
msg('atencao', 'Ocorreu um erro ao atualizar o registro!', '#resposta');
}});
Before they question the route is working right what I can not do is get the return value.