Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:46:15+00:00 2026-06-13T11:46:15+00:00

I am making a post via Jquery ajax that looks like this: $.ajax({ type:

  • 0

I am making a post via Jquery ajax that looks like this:

$.ajax({
    type: 'POST',
    url: "/sandbox/read_demands/",
    data: {
        "partner_ref": "PH",
        "return_field": ["summary", "details"]
    },
    success: [read_demands_response],
    dataType: 'json'
});

I then recieve the data on the server-side with a simple Django view that only prints request.POST into a log. The data then looks like this:

{u'return_field[]': [u'summary', u'details'], u'partner_ref': [u'PH']}

As you can see, the key ‘return_field’ has become ‘return_field[]’ and the value for ‘partner_ref’ is now a list. What on earth is going on? Am I missing something complected obvious in the jquery post that causes my data to be malformed or is do you think this error comes from somewhere else? I am trying to rule-out different possibilities until I can find the cause of the problem.

This is jquery 1.8.2 and Django 1.4 btw.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:46:16+00:00Added an answer on June 13, 2026 at 11:46 am

    The first one is just jQuery being jQuery. For reasons best known to themselves, the makers of jQuery believe that PHP is the only way to write server-side applications, and PHP expects fields that have more than one value to have the [] suffix – so if you don’t provide one, it’ll add it. You just have to use it like that in Django.

    However, the second one is not an error. It’s just how a Django QueryDict works: any value can have multiple items, so they’ll always be represented as a list. However, request.POST['partner_ref'] will correctly give the single value. And in fact to access both values of the other key, you’ll need to do request.POST.getlist('return_field[]').

    Edit: as pointed out in the comments, $.ajaxSettings.traditional = true; fixes the jQuery issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple POST request via jquery's .ajax function to a routed URL
I can't seem to authenticate by making a POST request via ajax! I always
Below is my javascript function that makes an ajax call via post. It sends
I am sending data via jQuery's .ajax method to my PHP file. Both files
I am making a function so that I can post from Ajax using a
I am posting form data to a page that is using jQuery tabs. Because
I'm making a quotes and phrases site. I want to post this quotes and
I'm making a ajax call using jQuery I'm making use of the following options
So, I'm experiencing a very frustrating problem. I am making an AJAX call (via
This is beyond both making sense and my control. That being said here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.