Repository navigation
5.0.0-beta.1
Pre-release5.0 is a major release with breaking changes. Read the migration guide before upgrading: each change below links to its entry, with who is affected and before and after code. With $.fn.ajaxSubmit.debug = true, the latest 4.x logs a warning for most of the features 5.0 removes. 4.x stays available (npm install jquery-form@4) and gets security fixes on a best-effort basis, with no set end date; see the security policy.
Install the beta
npm i jquery-form@nextjquery is now a peer dependency, so install it too if your project does not list it: npm i jquery@^3.7.1 jquery-form@next. The beta is on the next dist-tag; npm i jquery-form still installs 4.x. Please report problems on #629 or in a new issue. The pull request is #646.
Highlights
- Sends what a native submission sends. Fields follow tree order, only buttons, inputs, selects and textareas are sent, and image buttons,
dirname,_charset_and empty file inputs follow the HTML spec. The guide's "What your server receives" table shows each request body before and after. - A smaller, modern plugin. jQuery 3.5+ only, current browsers only, ES2020 syntax with no transpile; the jQuery < 3, Internet Explorer, Opera Presto and EdgeHTML code is gone. The minified build is 23.8 kB (9.1 kB gzip), down from 26.5 kB (10.1 kB gzip) in 4.6.0.
- An
exportsmap. Nodeimportgets the module build, bundlers get it forimportandrequire, andrequirein Node keeps the CommonJS factory. - Selector options are only selectors. A string in
target,iframeTargetorincludeHiddenis never parsed as HTML, so it can't create elements.
Breaking changes
Platform
- jQuery 3.5 or later is required, as a peer dependency.
peerDependencies: { "jquery": ">=3.5.0" }; on an older jQuery,ajaxSubmitandajaxFormthrowjquery.form 5 needs jQuery 3.5 or later; this is <version>. Tested on jQuery 3.5.0, 3.7.1 and 4.0.0. - Internet Explorer, Opera Presto and EdgeHTML are no longer supported. Current Chrome, Edge, Firefox (and ESR) and Safari; the builds need Chrome or Edge 80, Firefox 78 or Safari 14 or later. The
iframeSrcdefault isabout:blankon every page.
Packaging
- The package has an
exportsmap. Nodeimport "jquery-form"loadsdist/jquery.form.mjs(it needs a globalwindowanddocument) instead of the CommonJS factory; paths outsidedistandpackage.jsonno longer resolve. srcis no longer published. Importjquery-formorjquery-form/dist/jquery.form.mjsinstead ofjquery-form/src/....form.jquery.jsonis removed.
Removals
$.fn.attr2is removed: use.prop()or.attr().clearInputsis removed: useclearFields.closeKeepAliveis ignored.semanticis ignored: fields are always sent in tree order.delegation: truethrowsjquery.form: delegation needs a selector in 5.0, e.g. delegation: "form.ajax". Pass the selector:$(document).ajaxForm({ delegation: "form.ajax" }).ajaxFormon an empty selection before the DOM is ready no longer waits.- The iframe transport is used only with
iframe: true: uploads always useFormDataotherwise. enable()andselected()stay, unchanged.
Behavior and serialization
- Iframe
.doneand.thenreceive the parsed data, assuccessand$.ajaxdo. - Replacing
$.fieldValueno longer changes what is sent: use jQueryvalHooks. - Selector options are never parsed as HTML; a positional pseudo-class in
includeHiddentests each element alone. - Fields are sent in tree order.
- Only buttons, inputs, selects and textareas are sent.
- A clicked image button sends only its coordinates; check
name.xon the server. - A clicked image button without a name sends
xandy. - Controls with
dirnamesend their direction, on every transport, including a clicked submit input's field in iframe uploads. - A hidden
_charset_input sendsUTF-8. - An empty file input is sent as an empty file in uploads.
- Iframe uploads send the submitter at its place.
Kept on purpose (see Differences from a native submission): a selected file makes the request multipart without enctype, a GET request keeps the action's query, and a clicked submit input without a value sends an empty value.
The iframe transport: tell us if you use it
5.0 keeps the hidden-iframe upload transport, but only when you pass iframe: true; every other upload uses FormData. It may be removed in 6.0. If you use iframe: true, comment on #629 with your use case.
Docs
- A new migration guide, in the docs site menu as "Upgrading to 5.0" and linked from the README, with a "New in 5.0" section.
- The API page documents every method, including
formToArray,enable,selectedand$.fieldValue, and lists what 5.0 removes. - The options page documents
includeHidden, the iframe rejection arguments that differ from$.ajax, and the deliberate differences from a native submission. - The examples are rewritten for 5.0, with no demo server and with server snippets that escape their output. The Form Fields page shows what
fieldValueandfieldSerializereturn, and the FAQ is rewritten. SECURITY.mdsupports 5.x, with 4.x fixes on a best-effort basis.
Testing (no effect on the published files)
- The suite runs on Chromium, WebKit and Firefox with jQuery 3.5.0, 3.7.1 and 4.0.0 (1112 tests per jQuery version), at 100% coverage.
- The serialization oracle and the end-to-end tests compare with a native submission; the differences from a native submission that 5.0 removes are no longer allowed in them.
- Published-file tests check each
exportskey, Nodeimportresolving to the module build, themodulecondition, and that a deepsrcimport fails. - Every breaking change has a test that fails on 4.6.0 and an entry in the migration guide.
- The package is published from CI with npm provenance; pre-releases go to the
nextdist-tag.