Drupal AJAX
As of Drupal 11.3, HTMX is available in core and is the recommended approach for new projects. This guide covers the legacy AJAX framework, which remains essential for existing codebases and contributed module patterns.
| I need to... | Guide |
|---|---|
| Understand the AJAX system architecture | Core Concepts |
| Add AJAX to a form element | Form Element AJAX Configuration |
| Create dependent fields (category/subcategory) | Dependent Field Patterns |
| Build a multi-step wizard form | Multi-Step Form Workflows |
| Validate fields as user types | Live Field Validation |
| Update, append, or remove DOM content | Content Manipulation Commands |
| Add CSS classes or invoke jQuery methods | CSS Styling Commands |
| Open or close modal dialogs | Dialog Commands |
| Show messages or screen reader alerts | Feedback Commands |
| Create a custom AJAX command | Custom AJAX Commands |
| Build a custom AJAX route (non-Form API) | Custom Route Implementation |
| Handle file uploads via AJAX | File Upload Patterns |
| Implement autocomplete suggestions | Autocomplete Implementation |
| Restrict access to AJAX callbacks | Access Control Patterns |
| Protect AJAX endpoints from CSRF | CSRF Protection |
| Optimize slow AJAX requests | Performance Optimization |
| Cache AJAX responses | Response Caching |
| Make AJAX meet WCAG 2.1 AA | WCAG Compliance Patterns |
| Announce updates to screen readers | Screen Reader Support |
| Debug failing AJAX requests | Debugging Techniques |
| Write automated AJAX tests | Testing AJAX |
| Integrate React or Vue with Drupal | Frontend Framework Integration |
| Apply security best practices | Best Practices: Security |
| Apply performance best practices | Best Practices: Performance |
| Follow Drupal development standards | Best Practices: Development Standards |
| Meet accessibility requirements | Best Practices: Accessibility |