Problem/Motivation
- The jQuery Form plugin is not even fully compatible with jQuery 3 (see https://github.com/jquery-form/form/issues/544). However jQuery 4 is already in beta and we need to update to it, see #3411839: Update to jQuery 4.0.x beta.
- Efforts were also underway earlier to remove jQuery from core: #3052002: [meta] Replace JQuery with vanilla Javascript in core. That would include removing the jQuery Form plugin.
- The jQuery Form plugin is no longer maintained.
- The only use of the jQuery Form plugin in Drupal core is where misc/ajax.js calls
$.ajaxSubmit()
. The jQuery Form plugin provided an implementation of that that worked for old browsers. With modern browsers, we can useFormData
andfetch()
directly without needing to rely on either jQuery Form's$.ajaxSubmit()
or even jQuery's$.ajax()
. - One more usage is https://jquery-form.github.io/form/form-fields/ fieldValue() function in same ajax.js:895
Steps to reproduce
Proposed resolution
- In misc/ajax.js, replace the call to
$.ajaxSubmit()
withfetch()
if possible, or$.ajax()
if that's an easier step and we can then replace$.ajax()
withfetch()
in a followup. - For BC, we should preserve at least some of the existing events, like
beforeSerialize()
,beforeSubmit()
, andbeforeSend()
. If in addition to those 3 it makes sense to preserve all of the existing$.ajax()
events, that might be a point in favor of using$.ajax()
overfetch()
for now, especially if that can work easily enough withFormData
.