Search ajax with laravel 5.6 and jquery [closed]

1

I'm having trouble running a ajax search with laravel, it follows the ajax code of my view:

 $(document).ready(function () {
  $('#enviarForm').click(function (e) { 
    e.preventDefault();
    var form = $('#filtro').serialize();

    $.ajaxSetup({
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
              }
          });
          $.ajax({
            type: "get",
            url: "{{url('/cadastro')}}",
            data: form,
            dataType: "json",
            success: function (response) {
              alert('ola');
            }
          });
  });
});

Controller code:

if($request->ajax()){
        $nome = $request['ds_paciente'];
    $Pessoas=\App\Pessoas::where('ID_CD_TIPOPESSOA',1)
                           ->where('IN_STATUS',1)
                           ->where('NM_PESSOA', 'LIKE', '%' . $nome . '%')
                            ->paginate(10);

    return view('todosPacientes',compact('Pessoas'));
    }

I'm a bit lost and I'm not finding tutorials on the internet.

    
asked by anonymous 04.07.2018 / 18:12

0 answers