AJAX is an extremely powerful tool for bridging the gap between your server side code and your client-side code. It enables you to not only make better interfaces and more useful tools, but to lower your bandwidth usage and optimize your code while you’re at it.
While AJAX can be implemented freely anywhere, WordPress has built-in support for it, and there is a standard way to use it in your themes and plugins. Let’s take a look at the steps necessary to get going with AJAX.
The AJAX Flow
As you may well know, to create something useful using AJAX you’ll need a few things:
- An action which triggers the call
- An AJAX call
- Server side code which is executed
Not all these steps are required all the time, but in general this is how it goes. Let’s continue by thinking up a scenario where AJAX would be useful.