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

157
Vistas
'[]' appended to the end of my post request parameter in javascript

I am trying to make post request with the following parameters:

const postParams = { 'submission': submission };

However, when the request is actually sent, I observe that submission becomes submission[] in the browser's network tab. This is problematic because my server expects submission and not submission[]. Check the image below for more information.

[Note that the [] was appended to submission][1] [1]: https://i.stack.imgur.com/pXpNq.png

Note that submission (the variable) is an array of integers, so while it makes sense why the [] is attached, is there a way to get rid of that?

Below is the full function.

    const postParams = {  submission: str_sub };
    console.log(postParams)
    $.post(root+'/problems/multiple_choice/'+problem_pk+'/run',
            postParams,
            function(data) {
               // Omitted / not relevant
            })
     .fail(function(jqXHR, textStatus, errorThrown) { console.log(textStatus); });
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is jQuery's default behaviour where it follows PHP (instead of traditional) conventions.

See the documentation.

Use .ajax instead of .post and include traditional: true in the options object.

$.ajax(
    root+'/problems/multiple_choice/'+problem_pk+'/run',
    {
        data: postParams,
        traditional: true,
        success: (data) => { ... }
    }(    
about 4 years ago · Santiago Trujillo 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