Problem/Motivation
- Efforts are underway to remove jQuery from core: #3052002: [meta] Replace JQuery with vanilla Javascript in core. That includes 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()
.
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
.