Skip to main content

Bug Tracker

Side navigation

#14817 closed bug (notabug)

Opened February 18, 2014 03:56PM UTC

Closed February 18, 2014 10:04PM UTC

Sending complex object via AJAX

Reported by: LAci Owned by: LAci
Priority: undecided Milestone: None
Component: unfiled Version: 1.11.0-rc1
Keywords: Cc:
Blocked by: Blocking:

If you would like to send a complex object via AJAX, the generated parameter in mimetype application/x-www-form-urlencoded is not correct. The server component (e.g Spring/Struts) is unable load load it.

This is the JSON format of the object:


Generated format is:


The correct format would be:


Associated array ([attr1]) is not handled but it would be good with object format (.attr1).

Correction in 1.11 version:

line 9495

buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );


buildParams( prefix + "." + name + "", obj[ name ], traditional, add );

Correction in 2.0 version:

line 8368

buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );


buildParams( prefix + "." + name + "", obj[ name ], traditional, add );

Attachments (0)
Change History (4)

Changed February 18, 2014 04:12PM UTC by LAci comment:1

Changed February 18, 2014 04:47PM UTC by dmethvin comment:2

owner: → LAci
status: newpending

Can you point to a governing standard for serializing complex objects to www-form-urlencoded?

Changed February 18, 2014 09:39PM UTC by LAci comment:3

status: pendingnew

In www-form-urlencoded both are fine. It depends on the content. (Note: object or array).

Because we do not use associative array, and the server side application (in Java) calls the setters based on the incoming names (with the values as parameters). We need "." separator here. I think it comes from one of Java/JSP standards.

I understand the problem: there is no big differences between associative arrays and objects in JavaScript. This code could not know which was the original data structure. So the implemented code is correct and this issue is not a bug!

But it could be better (a feature) if jQuery developers could define somehow (with an optional parameter) the mapping format (for each level objects).

For example: buildParams(prefix, name, traditional, add, listOfItemsWhichAreAssociativeArrays)

So, please, close this issue, and create a new one as improvement with the right deseign based on this discussion.


Changed February 18, 2014 10:04PM UTC by dmethvin comment:4

resolution: → notabug
status: newclosed

The serialization logic built into jQuery is meant to allow simple form-like structures to be sent as if they were coming from a web page. This use case of complex nested structures isn't typical and can't occur in an HTML form.

There is already a standard way to serialize a complex JavaScript object to a string, and that is JSON. What you are requesting is that jQuery add a new non-standard way, and I can't think of a reason to do that.