Remove jQuery Form dependency from misc/ajax.js

Created on 21 December 2020, over 3 years ago
Updated 21 May 2024, 2 months ago

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 ๐Ÿ“Œ Update to jQuery 4.0.x beta Active .
  • Efforts were also underway earlier to remove jQuery from core: ๐ŸŒฑ [meta] Replace JQuery with vanilla Javascript in core Active . 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 use FormData and fetch() 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() with fetch() if possible, or $.ajax() if that's an easier step and we can then replace $.ajax() with fetch() in a followup.
  • For BC, we should preserve at least some of the existing events, like beforeSerialize(), beforeSubmit(), and beforeSend(). 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() over fetch() for now, especially if that can work easily enough with FormData.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Javascriptย  โ†’

Last updated about 1 hour ago

  • Maintained by
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom @justafish
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance @nod_
Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States bnjmnm Ann Arbor, MI

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024