jeudi 27 août 2015

AJAX post not sending data to laravel controller

Maybe this is a very common topic, but i can't find any solution!, the app i'm developing is under Laravel 5.0, i need to send some data from jquery ajax to a laravel controller, i've followed this tutorial to post data using ajax, i've followed the steps and made the global configuration, so that i have a meta with the csrf token, when i send the post request to a url using ajax, it just sends the token!! but nothing of the data i give it to send!

Here's my ajax func (i'm using dummy data to test it):

        $.ajax( {
            url        : '/reservacion/paso-uno/enviar',
            method     : 'post',
            data       : { name: "John", location: "Boston" }
        } );

but when i dd(\Request::all()); in the post func i only get the token, also if i check the headers form data i only get this:

data sent through the post

Here's a complete image of the headers: headers

Here's the meta tag with the csrf:

<meta name="_token" content="{{{ csrf_token() }}}"/>

And here's the global ajax setup:

$.ajaxSetup({
                headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
            });



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1PBCykt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire