Click one button below. Each button element contains a data attribute that can be used by JavaScript.
Ajax enables us to communicate with the server, access a file or a database there, and come back to our page and alter its contents without reloading the page. Often Ajax is also used to send data from the page (often from a form) to a script on the server, and often the server-side script will access a database.
In this example, there is no form and no database. There's just a second HTML file that you never see in the browser.
Each time you click any button here, the Ajax code accesses the file states.html on the server.
Side note: Learn more about data attributes and accessing their values with jQuery.
Ajax is probably going to be replaced by Fetch in the near future. Here is this same example done with Fetch instead of Ajax.