Skip to main content

Bug Tracker

Side navigation

#6481 closed bug (fixed)

Opened April 25, 2010 05:02PM UTC

Closed April 16, 2011 04:13PM UTC

Last modified March 15, 2013 02:32PM UTC

revert $.param should treat empty arrays/objects like empty strings

Reported by: temp01 Owned by:
Priority: blocker Milestone: 1.6
Component: ajax Version: 1.4.2
Keywords: param,regression,ajaxrewrite Cc:
Blocked by: Blocking:
Description

$.param ignores the key completly if the value is an empty object or array:

$.param({"foo": {"bar": []} });         // -> ""
$.param({"foo": {"bar": [], foo: 1} }); // -> "foo%5Bfoo%5D=1"
$.param({"foo": {"bar": {}} });         // -> ""

Empty values should be treated like empty strings i.e. (expected output):

$.param({"foo": {"bar": []} });         // -> "foo%5Bbar%5D="
$.param({"foo": {"bar": [], foo: 1} }); // -> "foo%5Bbar%5D=&foo%5Bfoo%5D=1""foo%5Bfoo%5D=1"
$.param({"foo": {"bar": {}} });         // -> "foo%5Bbar%5D="
Attachments (0)
Change History (20)

Changed September 24, 2010 08:57PM UTC by john comment:2

priority: → undecided
resolution: → fixed
status: newclosed

Changed November 16, 2010 05:20PM UTC by anonymous comment:3

Wish this would have been configurable (like using "traditional") for backwards compatibility.

Changed December 17, 2010 12:10PM UTC by rekna1@gmail.com comment:4

This breaking previous behaviour !! You can not simply change this behaviour.. it breaks existing code!

Changed December 17, 2010 05:38PM UTC by anonymous comment:5

Like mentioned in http://forum.jquery.com/topic/change-of-behavior-in-1-4-4-because-of-bug-6481, it think the default implementation should be the way the browser does it... there is no element for an empty array (cfr the example with checkboxes with the same name attribute!!! )

Changed December 17, 2010 08:48PM UTC by dmethvin comment:6

milestone: 1.4.3
resolution: fixed
status: closedreopened

Reopened for possible reversion. See the discussion in the forum thread. Vote on this ticket (at the top of the page) if you 're interested.

Changed December 27, 2010 06:20AM UTC by snover comment:7

keywords: paramparam regression

Changed December 27, 2010 10:37PM UTC by rwaldron comment:8

keywords: param regressionparam,regression,ajaxrewrite

Changed February 02, 2011 03:16PM UTC by dmethvin comment:9

milestone: → 1.6

Changed February 04, 2011 03:42PM UTC by vig comment:10

Replying to [comment:9 dmethvin]:

This fix seems to have got included in the 1.5 version

Changed February 04, 2011 04:46PM UTC by jitter comment:11

Replying to [comment:10 vig]:

Replying to [comment:9 dmethvin]: This fix seems to have got included in the 1.5 version

The "fix" is in since jQuery 1.4.3 .

The ticket was reopened to evaluate if the fix should be reverted as it breaks previous behavior. Check http://forum.jquery.com/topic/change-of-behavior-in-1-4-4-because-of-bug-6481 for the discussion

Changed February 06, 2011 04:31PM UTC by snover comment:12

priority: undecidedblocker
status: reopenedopen
summary: $.param should treat empty arrays/objects like empty stringsrevert $.param should treat empty arrays/objects like empty strings

The problem is that there is no way to serialize an empty array in a way that makes sense in the x-www-form-urlencoded format. foo[bar]= could either mean empty array, empty string, empty object, or null/undefined value, depending upon how the backend chooses to interpret it. Since neither way of serialization is really “correct”, and most backends interpret this as “empty string”, and this breaks traditional mode in quite a bad way (as per the forum thread), I’m marking this to block 1.6 so it can be reverted back to the old behaviour.

Changed March 29, 2011 12:35PM UTC by dmethvin comment:13

#8687 is a duplicate of this ticket.

Changed April 16, 2011 04:13PM UTC by john comment:14

resolution: → fixed
status: openclosed

Fix for this has been backed out - not something that we're going to try and fix.

Changed April 16, 2011 04:13PM UTC by john comment:15

type: enhancementbug

Changed April 18, 2011 01:21PM UTC by addyosmani comment:16

#8902 is a duplicate of this ticket.

Changed May 05, 2011 12:42AM UTC by Se precisar mande um EMAIL gabriel98765432184@hotmail.com comment:17

eu nao entendo nada sera que akguem do jquery poderia ajudar e ao enves de faser otras linguas que ninguem usa por favor traduzam em portugues isso assim muito mais pessoas poderao visualizar e usar mais este site e tenha certeza que eu teria prazer em divulgar

Changed May 20, 2011 02:36PM UTC by dmethvin comment:18

#9360 is a duplicate of this ticket.

Changed September 16, 2011 02:40PM UTC by dmethvin comment:19

#10292 is a duplicate of this ticket.

Changed March 15, 2013 02:32PM UTC by dmethvin comment:20

#13611 is a duplicate of this ticket.