Skip to main content

Bug Tracker

Side navigation

#11594 closed bug (wontfix)

Opened April 16, 2012 02:25PM UTC

Closed April 23, 2012 04:13PM UTC

Last modified October 15, 2012 08:36PM UTC

Serialize fieldset in Chrome and IE9

Reported by: jragsdale@phoenixwebgroup.com Owned by: jragsdale@phoenixwebgroup.com
Priority: low Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

.serialize() does not serialize form elements inside a fieldset in Chrome or IE9.

A test case is provided at http://jsfiddle.net/HQZts/

To reproduce the issue, open the above test case in the following browsers:

Firefox, Chrome, and IE 9.

fails:

Chrome and IE 9 on Windows 7 64-bit

works:

Firefox on Windows 7 64-bit

Attachments (0)
Change History (5)

Changed April 16, 2012 02:38PM UTC by dmethvin comment:1

owner: → jragsdale@phoenixwebgroup.com
status: newpending

It doesn't seem like this is a documented use of the method.

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 ... http://api.jquery.com/serialize/

So other than a form, there is no current use of .serialize() that requires the code to search inside an element for more elements to process.

Is there some documentation that implied it was correct to use a fieldset like this? At best I'd consider it an enhancement request and not a bug, but I'd prefer to just clarify the docs. It's easy to change the selector to get your desired effect.

Changed April 16, 2012 03:08PM UTC by jragsdale@phoenixwebgroup.com comment:2

status: pendingnew

I want to save bandwidth by sending only a subset of a form in certain cases. Likely, there are workarounds where I can use nested forms to get my desired results.

In the first paragraph of the documentation, there is a sentence that reads, "It operates on a jQuery object representing a set of form elements." A fieldset can contain form elements, thus the confusion.

I am not the first to encounter similar confusion:

http://bugs.jquery.com/ticket/9863

http://stackoverflow.com/questions/8166991/jquery-serialize-and-serializearray-is-not-working-with-google-chrome

Simplest solution is to make the documentation more clearly express the limitations of .serialize() on elements other than the root form.

Changed April 16, 2012 03:51PM UTC by ajpiano comment:3

keywords: → needsdocs

I don't think adding a note about using it on fieldsets is a terrible idea, so +1 for that. This could perhaps be phased in terms of explaining that "a collection that contains an element that contains form elements is not the same as a collection that contains form elements." Using the word "represent" is probably misleading here.

But in terms of workarounds, I just thought it's worth noting that $("#someFieldset :input").serialize() is probably a wiser move than nested forms, etc, so I wanted to chime in with that.

Changed April 23, 2012 04:13PM UTC by rwaldron comment:4

component: unfiledajax
priority: undecidedlow
resolution: → wontfix
status: newclosed

Closing this as wontfix, docs pending.

Changed October 15, 2012 08:36PM UTC by mikesherov comment:5

keywords: needsdocs