Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#13357 closed bug (notabug)

serialize() behaves inconsistently for fieldset

Reported by: mikecapp Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:

Description

I have a large-ish form already organized into fieldsets, and I want to serialize a subset of those fields for an AJAX call. The obvious approach was $("#somefieldset").serialize(), but while this works in Chrome it returns nothing in IE7. It's not clear from the docs whether this *should* work, but if not the results should at least be consistent.

$("#somefieldset input").serialize() is fine as a workaround, so this isn't the end of the world.

Fiddle: http://jsfiddle.net/mikecapp/rSwUW/

Chrome output: core1=one&core2=two

IE7 output: nothing!

Change History (2)

comment:1 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

The method is consistent with its documentation. There's no mention of handling the <fieldset> container element.

The .serialize() method can act on a jQuery object that has selected individual form elements, such as <input>, <textarea>, and <select>. However, it is typically easier to select the <form> tag itself for serialization

It can take either a <form> element (in which case it will serialize the form.elements property) or a jQuery set of form inputs. It may be possible to pass in other things and get outputs but they're not documented.

comment:2 Changed 5 years ago by gibson042

#15191 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.