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

180
Vistas
JavaScript POST non-API request with repeated keys in payload

Javascript. POST request. It is not an API request (axios or fetch), but the old classical request.

I need a payload like ...&_selected_action=5&_selected_action=10. So I think I cannot use a form submitting technique here. With a single occurence ...&_selected_action=5 I am able to do it (form submitting as Aquajet @ pass post data with window.location.href), everything works well. For the repeated value I can create the string by hand or by URLSearchParams().toString() but I am not able to send it.

Any idea?

More details. I need create this request in Django+Vue application which partially replaces the old school Django Admin. The ListView is replaced using Vue and now I want to reuse the actions where Django Admin uses Post request formatted as above. So with single selected row in list I am able to do it, but with 2+ selected rows I cannot find a good way how to do it.

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

0

In my question above I am not true that I cannot use form submitting method. Of course, html form can have more fields with identical name= and if so, its submit generates a post request exactly as needed.

But while I create the form programmatically, I cannot fill it from dictionary, because dictionary cannot have repeated keys.

So I have modified the function proposed by Aquajet here pass post data with window.location.href and I check if params[key].constructor !== Array. I convert non-array values to array (with single element) and I cycle through such arrays. This allows me to have repeated values in the parameter (in such case I enter them as an array) and in the form.

So, this is answer to my problem. However it is a little strange to create lot of hidden inputs for such goal. So I am interested if there is a better way how to create the POST request.

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