Skip to main content

Bug Tracker

Side navigation

#13651 closed bug (invalid)

Opened March 22, 2013 06:31PM UTC

Closed April 06, 2013 08:42AM UTC

Last modified December 02, 2013 04:30PM UTC

$(form).serialize() fails when the form has an element with ID/name equals "elements"

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

$(form).serialize() fails if the HTML form has an input or select control with ID (or possibly with the name attribute) set to "elements". This seems to be because the $.serialize() function looks for all "properties" of form "this" having a key equals to "elements". But the input/select form control having its id="elements" seems to override that form property somehow, thus resulting in the serialization of an empty array of form elements :(

For example, attempting to serialize a form defined as such:

<form id='perioricTableSubmissionForm'>
  <input id="professor" name="professor"/>
  <select id="department" name="department">...</select>
  <select id="elements" name="elements[]" multiple>...</select>

Would return a blank string when calling


because the serialize() method in jQuery does something like this:

var elements = $.prop(this, "elements");
Attachments (0)
Change History (4)

Changed March 22, 2013 08:53PM UTC by rwaldron comment:1

owner: →
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists—you may need to change this to a specific version depending on the test case.

To get you started, use the appropriate boilerplate:

Open the link and click to "Fork" (in the top menu) to begin.

Also, please read:

Changed March 23, 2013 12:03AM UTC by dmethvin comment:2

This sounds like our old friend DOM property aliasing, which we can't fix.

Changed April 06, 2013 08:42AM UTC by trac-o-bot comment:3

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed December 02, 2013 04:30PM UTC by timmywil comment:4

#14594 is a duplicate of this ticket.