Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
'[]' 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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda