Skip to main content

Bug Tracker

Side navigation

#4177 closed bug (worksforme)

Opened February 18, 2009 12:28AM UTC

Closed February 18, 2009 12:50AM UTC

Last modified March 14, 2012 02:46PM UTC

jQuery.param() handles arrays very strangely

Reported by: wmleler Owned by:
Priority: minor Milestone: 1.3.2
Component: core Version: 1.3.1
Keywords: param array Cc:
Blocked by: Blocking:

If you create an object containing an array, and pass it to jQuery.param(), it creates two name/value pairs with the same name, which is not valid HTTP.

For example, $.param({ a: [5, 12], b: 'hello' }) creates a=5&a=12&b=hello

If I use this as a query string into PHP, it only sees a=12 (the 5 is lost).

Attachments (1)
  • bug2.html (0.6 KB) - added by wmleler February 18, 2009 12:29AM UTC.

    small program to reproduce the bug

Change History (1)

Changed February 18, 2009 12:50AM UTC by dmethvin comment:1

resolution: → worksforme
status: newclosed

I'm not sure what you mean by "not valid HTTP" since isn't related to the HTTP protocol. Try this sample code:

<form method="get" action="">
<input type="checkbox" name="checker" value="1">
<input type="checkbox" name="checker" value="2">
<input type="checkbox" name="checker" value="3">
<input type="submit" value="submit">

It will submit a GET request like this:

That would be equivalent to passing

checker: [1,2,3]

PHP handles multivalued forms in a nonstandard way, so that may be what is causing confusion: