I have a project in which I have to send the CPF of a patient to a method in the controller in order to search within this method and already return the search value to the view, but I am not able to send those values to the view.
Update I am already getting access to the controller and return the object to ajax but I am still not able to access it in ajax. no error appears and I can check on the network that the controller method is returning the data correctly. follow new updated code:
controller
public function verificarCadastro (Request $request){
return \Response::json($this->paciente->where('cpf',$request->cpf)->get());
}
ajax na view
function buscarCpf() {
cpf = $('#cpfBusca').val();
$.ajax({
url: window.location.href+"/verificar-cadastro",
type: "POST",
data: {"cpf": cpf,"_token":"{{csrf_token()}}" },
cache: false,
processData: true,
dateType:'json',
sucess: function(data) {
if(data.cpf != null)
console.log(data.cpf);
},
erro: function(data){
console.log(data);
}
});
//window.location.href = caminho;
};
Return on the network