4
I have the code below that does a check on my controller and it returns me a Count of my request.
What I wanted is that in the sucess of my ajax Jquery I capture this value to make some negotiations by javascript in my code.
I’m using the Laravel 5.2 framework.
Follow the code of 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 you question the route is working right what I can’t get is the return value.
What output do you print on the console ? You’ve tried accessing the route manually to see what results ?
– SCOFIELD
The route returns fine, but when I check the return on the console is blank!!!!
– Carlos Henrique Carniatto