Error using Ajax Uncaught RangeError: Maximum call stack size exceeded

1

I want to pass some data by POST using AJAX to insert in database I am working in laravel 5.1.

My question is this:

Is there a limit to the parameters that can be sent by Ajax? Because I have several and if I remove one nothing happens, insert but if I put it gives javascript error.

Code:

$.ajax({
    type: 'POST',
    url:'/estimates',
    dataType:'json',
    headers: {'X-CSRF-TOKEN': token},
    //  data:{DatosEstimado:DatosEstimado,Estimado:Estimado,descuento:descuento,gananciatotal},
    data: 
         {
           company_id:company_id,prove_id:prove_id,estado:estado,
           fecha_soli:fecha_soli,resumen:resumen,metodo:metodo,
           proximo_seguimiento:proximo_seguimiento,
           fbo:fbo,cantidad_fuel:cantidad_fuel,localidad:localidad,
           avion_id:avion_id,tipoCama:tipoCama,
           Estimado:Estimado, descuento:descuento,
           totalDescuento:totalDescuento,
           gananciatotal:gananciatotal,
           total:total,subtotal:subtotal,tipoCategoria:tipoCategoria
          },
    success: function (estimado) {
      $('#mensaje').toggleClass('alert alert alert-success');
      $('#mensaje').html(estimado);
      console.log(estimado);
      //  window.location()
      //   location.href ="/estimates/index";
      //Recargar el plugin para que tenga la funcionalidad del componente$("#idMunicipio").select({ placeholder: "Selecciona un Municipio", width: "20%" });
        },
        //Mensaje de error en caso de fallo
        error: function (ex) {
          $('#mensaje').toggleClass('alert alert alert-danger');
          $('#mensaje').html('Ocurrio un error inesperado: '+ex);
            alert('Failed to retrieve states.' + ex);
        }
  });
    
asked by Josmer Martinez Moya 04.03.2017 в 14:29
source

1 answer

1

The error may be due to several Ajax attempts to serialize your JSON. Then, we better serialize it before sending it using JSON.stringify () :

//Pongo el arreglo en una variable, sólo para que el código quede más amigable
        var miData = {
           company_id:company_id,prove_id:prove_id,estado:estado,
           fecha_soli:fecha_soli,resumen:resumen,metodo:metodo,
           proximo_seguimiento:proximo_seguimiento,
           fbo:fbo,cantidad_fuel:cantidad_fuel,localidad:localidad,
           avion_id:avion_id,tipoCama:tipoCama,
           Estimado:Estimado, descuento:descuento,
           totalDescuento:totalDescuento,
           gananciatotal:gananciatotal,
           total:total,subtotal:subtotal,tipoCategoria:tipoCategoria
          };


$.ajax({
    type: 'POST',
    url:'/estimates',
    dataType:'json',
    headers: {'X-CSRF-TOKEN': token},
    //  data:{DatosEstimado:DatosEstimado,Estimado:Estimado,descuento:descuento,gananciatotal},
    data: JSON.stringify(miData),
    success: function (estimado) {
      $('#mensaje').toggleClass('alert alert alert-success');
      $('#mensaje').html(estimado);
      console.log(estimado);
      //  window.location()
      //   location.href ="/estimates/index";
      //Recargar el plugin para que tenga la funcionalidad del componente$("#idMunicipio").select({ placeholder: "Selecciona un Municipio", width: "20%" });
        },
        //Mensaje de error en caso de fallo
        error: function (ex) {
          $('#mensaje').toggleClass('alert alert alert-danger');
          $('#mensaje').html('Ocurrio un error inesperado: '+ex);
            alert('Failed to retrieve states.' + ex);
        }
  });
    
answered by 04.03.2017 в 18:05