How to debug an ajax request for a laravel route?

1

I'm doing an AJAX request on a route, using laravel, as follows:

$.ajax(
        {
            url: "../controle/pendentes/concluirVarias",
            type: "POST",
            data: {  ids: arrayIds , _token: '{!! csrf_token() !!}' },
            dataType: "html",
            success: function(data) {
                console.log(data);
            }
        }
    );

ArrayIds is an array that is declared above, getting some pushs.

The route file has the following route:

 Route::group(['prefix' => '/controle'], function() {
    //rota que irá marcar alguma carteirinha pendente como 'concluída'
    Route::post('/pendentes/concluirVarias/', function() {

        $input = Input::only('ids'); //recebe um array de ids
        $input = $input['ids']; 

    //percorre todos os ids e seta 'pendente' = 0
        foreach($input as $id) {
            $aluno = new App\Aluno();
            $aluno = $aluno->where('id', '=', $id)->first();
            $aluno->pendente = '0';
            $aluno->save();
        }

    });
    }   

No student is having the 'pending' variable changed to 0.

In the console, when I activate the function that has AJAX, I get the return of an HTML from the current page.

On Network, after running ajax, 'completeVariations' appears in 'name'. When I click, to see the preview, I see the actual HTML page itself.

In headers, in the 'Data Form' part, the array is normally passing, as I see it written:

  

ids []: 30   ids []: 13   ids []: 17   ids []: 12   ids []: 10   ids []: 5   ids []: 3   ids []: 16   ids []: 20   ids []: 21   _token: Jg1G2UpZHRmcMdcBqVDJCIuT8yUxN15Kt0BNaBRO

How do I debug the route part, for example, add a dd ($ input) or something, so I can see what is actually being passed to the route?

Thank you.

    
asked by anonymous 09.10.2017 / 00:53

0 answers