Ticket #1593 (closed bug: wontfix)
Serialize ignores buttons
| Reported by: | oridan | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.1 |
| Component: | core | Version: | 1.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
when specifically selecting a button and serializing it, it is no longer serialized properly, it used to give you:
buttonA=buttonValue
but it now returns an empty string.
Example:
<input id="buttonA" type='button' name="buttonA" value="buttonValue">
<script>
alert(jQuery("#buttonA").serialize());
</script>
Worked fine in 1.1.4, broken in 1.2
Change History
comment:2 Changed 6 years ago by oridan
ahh yes, i see. It does make more sense that way, since clicking a "button" doesnt normally get serialised, only clicking a "submit".
Many Thanks, Tom
comment:3 Changed 5 years ago by umonkey
John, what do you mean by "making it invalid"? Gecko based browsers do submit the value of a button (checked with Firefox and Epiphany), Opera does so to, W3C says it should be so. It's the only way to make multi-button forms localized, not just a silly feature for fun. Only IE implements it unlike the rest, as usual.
I understand that the goal of jQuery is to work equally in all browsers, rather than being standard-compliant, but this argumentation ("making it invalid") still sucks. Browsers do submit button values, jQuery does not. This is invalid.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

That's correct, we changed how serialization was done in 1.2 so that it will properly mimick how forms are actually serialized in a browser. We don't plan on reverting and making it invalid.
In the meantime you can just append the button name/value to the end of the string returned from serialize.