Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
Ajax Sending Null Parameters to Controller

I am trying to send 3 parameters using ajax to a Controller function. My ajax looks like

$.ajax({
    url: '../saveFields',
    data: {
           fields : fieldIDs,
           values : vals,
           ID : <%= this.Model.DatabaseID %>,
    },
    success: function (data) {
           alert("Success");
    },
    error: function (data) {
           alert("Failed");
    }
});

where fieldIDs and vals are arrays populated with integers. And the Controller call is

public ActionResult saveFields(int ID, int[] fields, int[] values)

I have a breakpoint set up right before the ajax call and the first line in the Controller function. Right before the ajax call, fieldIDs and vals are correctly populated, but then the first line of the Controller function the fields and values parameters are null. ID works fine. Any assistance as to what I am doing wrong would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Well, Jquery has different types of param serialization. Jquery Params

It turns out to fix that and pass an array correctly, you need to set the following property for the AJAX:

traditional: true
about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda