• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

257
Vistas
(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 3 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda