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

154
Views
'[]' 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 answers
Answer question

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 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!