Published: June 1, 2022
Have you ever had to decide between Fetch API and AJAX? When you are needing to get data from a remote API or PHP file, you have a few options within JavaScript. In this tutorial, I show you how to do it both ways. You can use jQuery for AJAX or vanilla JS for Fetch API.
AJAX has been tried and tested for years within jQuery and at one point was the go-to method. With Vanilla JS making a considerable comeback, new options like the built-it Fetch API are used more often. This is mostly due to its ease of use and since it is built into JavaScript, you no longer need a framework or library to use it.
00:00 Intro
01:21 Setup Our File Structure
02:56 Create Our index.html
06:28 Building Our jQuery AJAX Request
10:33 Building Our PHP File JSON (insert API if needed)
15:25 Formatting JSON AJAX Responses
20:04 Building Our Fetch API Request
27:06 Formatting JSON Fetch API Responses
30:19 Finishing Up
32:54 Course Announcement
Download tutorial files here: https://github.com/thedevdrawer/php-ajax-fetch
⭐ If you would like to buy me a coffee because I created something that helped you, it would be much appreciated! : https://www.buymeacoffee.com/devdrawer
⭐ Join this channel to get access to perks:
https://www.youtube.com/channel/UCcr8eSk5xCfn3AbYy8WOWzg/join
⭐ Become a Patreon to show support and get exclusive access to content: https://www.patreon.com/devdrawer