lundi 1 juillet 2019

ajax post returns laravel error 500 (Internal Server Error)

I added the csrf token and it still returns that error. Unfortunately everywhere I search is just telling me to add that to my view but if I already have that what am I supposed to do from here?

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

...

$('#like_unlike').on("submit", function( event ) {
            event.preventDefault();
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                }
            });
            $.ajax({
                url: '',
                type: 'post',
                data: {
                    _token : $('meta[name="csrf-token"]').attr('content'),
                    data:$('#like_unlike').serialize()
                }, // Remember that you need to have your csrf token included
                dataType: 'json',
                success: function( _response ){
                    console.log(_response)
                },
                error: function( _response ){
                    console.log('failure')
                }
            });
        });



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JvO0Dp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire