WordPress has its own way of implementing AJAX calls. In this video, we will explain as clearly as possible how to do AJAX requests in WordPress. I am considering that you are somewhat familiar with Javascript and PHP.
This video is divided into two sections. The first one explains what an AJAX call is. The second one is the step-by-step instructions for WordPress.
TLDR: If all you need are the JS and PHP code snippets for your request, here they are:
👉 / how-to-do-ajax-in-wordpress
AJAX is a technique that appeared in the late 1990s and early 2000s. The real revolutionary thing about it is that it used current technologies to do something extremely powerful and new: updating the content of your website without reloading the page.
Until then, if you wanted to update a simple button or the elements in your inbox, you would’ve needed to refresh the entire page. But reloading an entire page for only a single element is not very resource-effective.
What AJAX allows us to do is to update a particular part of your website with information from your server without refreshing the entire website.
------------------------------------------------------------------------------------------------------------------------------
🕒 Timestamps:
0:00 Introduction
2:22 What is AJAX
8:16 AJAX in WordPress
10:47 Set up your trigger
13:47 Set up your request
20:10 Handle your request
29:34 Axios and common errors
33:10 Conclusion