• Home
  • Jobs
  • coursesAndChallenges
  • Teachers
  • For business
  • Blog
  • ES/EN

0

21
Views
using Ajax with Laravel give me status 500

i'm using ajax with laravel for the first time and i have an error, it gives me status 500 Internal Server Error back.. Im sending the token and everything seems to be ok, can you guys check and maybe see where the problem is :), thanks a lot.

Code:

    jQuery(document).ready(function () {
        jQuery('#ajaxSubmit').click(function (e) {
            e.preventDefault();
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                }
            });
            console.log(listvalues)

            jQuery.ajax({
                url: "{{ route('downloadSelectedCsv') }}",
                method: 'POST',
                data: {
                    ids: listvalues,
                },

            });
        });
    });

Route: (Web.php)

Route::post('/download/csv', [\App\Http\Controllers\UrlController::class, 'downloadSelected'])->middleware(['auth'])->name('downloadSelectedCsv');

14 days ago ·

Santiago Trujillo

Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.