Consider switching `serialize`/`serializeArray` to FormData
Author: mgolCreated Feb 23, 2026Updated May 18, 2026
LabelsSerialize
BTW, I've been thinking about using
FormDatahere. We'd get all that filtering we're doing out of the box. There are a few issues, though:
valHookswould be skipped. Now, outside of IE we now only have them for multi-select andFormDataalready handles multi-select identically as we do. Therefore, it's mostly about hooks defined by userland code, plugins, etc. I'm not sure how common are those, but we could re-evaluate for 5.0.- FormData works nicely on forms, but
.serialize()can also be called on a collection of form elements, even if they're not lying in a form. I wish we didn't do this, serialization should always happen on the form level, but we do support it. I wonder how common such usage is compared to calling.serialize()on a form, but I wouldn't be surprised if it's common.
Originally posted by @mgol in #5245
To add to the above, during the team discussion @gibson042 suggested we may still try to do a version of it in 4.x by:
- Adding temporary
formprops to individual elements so thatFormDatahas a temporary form to work with. - Applying
valHooksafter FormData usage by finding elements with matchingnames and running the valHooks.
Source: jquery/jquery