#4177 closed bug (worksforme)
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: |
Description
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)
Change History (2)
Changed 14 years ago by
comment:1 Changed 14 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
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="http://google.com"> <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"> </form>
It will submit a GET request like this:
http://www.google.com/?checker=1&checker=2&checker=3
That would be equivalent to passing checker: [1,2,3]
to jQuery.param
.
PHP handles multivalued forms in a nonstandard way, so that may be what is causing confusion:
Note: See
TracTickets for help on using
tickets.
small program to reproduce the bug