Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
(Internal Server Error) ajax request and laravel 2022

I'm having an issue adding to the cart in laravel 8 with an ajax request When I click on the add to cart button an alert is supposed to pop but instead, I get the 500 (Internal Server Error) displayed on the console

First of all, I will show you my js code:

$('.addToCartBtn').click(function (e) { 
    e.preventDefault();
    
    var product_id = $(this).closest('.product_data').find('.prod_id').val();
    var product_qty = $(this).closest('.product_data').find('.qty-input').val();
    var flavour_id = $(this).closest('.product_data').find('.flav_select').val();
    var size_id = $(this).closest('.product_data').find('.size_select').val();

    $.ajaxSetup({
      headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
  });
 
   $.ajax({
       type:"POST", 
       //_method: "PUT",
       url:"/add-to-cart", 
       data: { 
           'product_id':product_id,
           'product_qty':product_qty, 
           'flavour_id':flavour_id,
           'size_id':size_id,
           },
            success: function (response) {
                alert(response.status ) ;
       } 
   });
}); 
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!