development

AJAX

AJAX (Asynchronous JavaScript and XML) is a web technique that sends and receives data from a server in the background — without reloading the entire page. The result: interactive page updates, l...

AJAX

This glossary entry is for WordPress site owners and freelancers who have seen “AJAX” in plugin settings, browser console errors, or performance audits — and want a plain-English definition before digging deeper.

AJAX (Asynchronous JavaScript and XML) is a web technique that sends and receives data from a server in the background — without reloading the entire page. The result: interactive page updates, live search, instant form submissions, and dynamic cart counts that respond immediately to user action.


Answer Capsule

AJAX is a browser technique that exchanges data with a server behind the scenes, updating parts of a page without a full reload. WordPress ships with a built-in AJAX handler at /wp-admin/admin-ajax.php; most dynamic plugins — contact forms, live search, WooCommerce cart — route requests through it as of WordPress 6.0+.


What does AJAX do in WordPress?

WordPress processes AJAX requests through a dedicated endpoint: https://yoursite.com/wp-admin/admin-ajax.php. Every plugin that needs dynamic behavior — a contact form that validates without reloading, a WooCommerce mini-cart that updates quantity live, or a live search bar — typically fires an AJAX call through this endpoint.

We see this pattern on nearly every client site we audit. The browser sends a small POST or GET request carrying an action parameter; WordPress maps that action to a PHP function registered via wp_ajax_ or wp_ajax_nopriv_ hooks, processes the request, and returns a JSON response. The page never reloads.


Where you’ll encounter it

Three places AJAX shows up in everyday WordPress work:

  • Plugin settings — Options like “Enable AJAX search” or “AJAX add-to-cart” toggle this behavior on or off.
  • Performance audits — In our testing, sites with poorly coded AJAX can fire 30–50+ requests on a single page load, each adding latency. Waterfall charts in Chrome DevTools make this visible immediately.
  • Console errors — A 400 Bad Request or 403 Forbidden on admin-ajax.php almost always means a missing nonce (a WordPress security token) or a misconfigured action hook.

A quick example

A form plugin might send this in the background when a user clicks Submit:

fetch('/wp-admin/admin-ajax.php', {
  method: 'POST',
  body: new URLSearchParams({
    action: 'submit_contact_form',
    nonce: wpVars.nonce,
    email: '[email protected]'
  })
})

WordPress receives it, validates the nonce, runs the registered PHP handler, and returns {"success": true} — all without touching the browser’s URL bar.


Performance note

admin-ajax.php loads the full WordPress stack for every request, including all active plugins. On shared hosting, this creates measurable overhead. The WordPress REST API introduced in WordPress 4.4 (2015) is a lighter alternative that many modern plugins now prefer. If you’re troubleshooting slow AJAX on a high-traffic site, switching to REST API endpoints — or caching AJAX responses with a plugin like WP Rocket — cuts server load significantly.


Additional reading: WordPress Plugin Handbook — AJAX in Plugins (official developer docs, last verified April 2026).