Use Ajax with Forms for Drupal 8, Drupal 9

Last updated February 19, 2021
Module Development8.9.x/9.0.x

Asynchronous JavaScript And XML (Ajax) is a programming practice for building more complex, dynamic webpages using a technology known as XMLHttpRequest. It allows you to asynchronously perform server-side operations without requiring a refresh, thus allowing for more complex user interaction and, in some cases, improved user experience.

In this tutorial we'll:

  • Define what Ajax is
  • Look at how Ajax is implemented in the Drupal Form API
  • Provide links to additional resources to learn more about implementing Ajax in your own forms

By the end of this tutorial you should be able to explain what Ajax is, when you might want to use it, and how to get started doing so with Drupal's Form API.