#6481 closed bug (fixed)
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="
Change History (20)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Priority: | → undecided |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 Changed 13 years ago by
Wish this would have been configurable (like using "traditional") for backwards compatibility.
comment:4 Changed 13 years ago by
This breaking previous behaviour !! You can not simply change this behaviour.. it breaks existing code!
comment:5 Changed 13 years ago by
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!!! )
comment:6 Changed 13 years ago by
Milestone: | 1.4.3 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
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.
comment:7 Changed 13 years ago by
Keywords: | regression added |
---|
comment:8 Changed 13 years ago by
Keywords: | ajaxrewrite added |
---|
comment:9 follow-up: 10 Changed 13 years ago by
Milestone: | → 1.6 |
---|
comment:10 follow-up: 11 Changed 13 years ago by
Replying to dmethvin: This fix seems to have got included in the 1.5 version
comment:11 Changed 13 years ago by
Replying to vig:
Replying to 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
comment:12 Changed 13 years ago by
Priority: | undecided → blocker |
---|---|
Status: | reopened → open |
Summary: | $.param should treat empty arrays/objects like empty strings → revert $.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.
comment:14 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fix for this has been backed out - not something that we're going to try and fix.
comment:15 Changed 12 years ago by
Type: | enhancement → bug |
---|
comment:17 Changed 12 years ago by
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
Commit link: http://github.com/temp01/jquery/blob/9f0b87f111f34cae54174a88210dea5ffa525c69/src/ajax.js