Bug Tracker

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#11594 closed bug (wontfix)

Serialize fieldset in Chrome and IE9

Reported by: jragsdale@… Owned by: jragsdale@…
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

Change History (5)

comment:1 Changed 8 years ago by dmethvin

Owner: set to jragsdale@…
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.

comment:2 Changed 8 years ago by jragsdale@…

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.

comment:3 Changed 8 years ago by ajpiano

Keywords: needsdocs added

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.

comment:4 Changed 7 years ago by Rick Waldron

Component: unfiledajax
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

Closing this as wontfix, docs pending.

comment:5 Changed 7 years ago by mikesherov

Keywords: needsdocs removed
Note: See TracTickets for help on using tickets.