Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!