AJAX Basics β Load Data Without Refreshing the Page
π What is AJAX?
- AJAX stands for Asynchronous JavaScript and XML.
- In simple words, AJAX allows us to send and receive data from server without reloading the web page.
π The page stays the same, only data changes.
πΉ Why Use AJAX?
β No page reload
β Faster response
β Better user experience
β Smooth website interaction
πΉ Where AJAX is Used?
- Login systems
- Search suggestions
- Live form validation
- Weather apps
- Chat applications
π§ How AJAX Works (Easy Steps)
1οΈβ£ User performs an action (click / submit)
2οΈβ£ JavaScript sends request to server
3οΈβ£ Server sends data back
4οΈβ£ Page updates without reload
πΉ Simple AJAX Example (Using Fetch)
fetch(“data.json”)
.then(response => response.json())
.then(data => {
console.log(data);
});
β What is an API?
- API stands for Application Programming Interface.
- In simple words, an API is a bridge that helps two applications talk to each other
π Example:
- Weather app gets data from weather server
- Payment app talks to bank server
πΉ Real Life Example of API
- Google Maps
- Weather apps
- Payment gateways
- Login with Google/Facebook.
πΉ API Call Example
fetch(“https://api.example.com/data”)
.then(response => response.json())
.then(result => {
console.log(result);
});
πΉ Display API Data on Page
fetch(“https://api.example.com/data”)
.then(res => res.json())
.then(data => {
document.getElementById(“output”).innerHTML = data.name;
});
πΉ Types of API Requests
- GET β Get data
- POST β Send data
- PUT β Update data
- DELETE β Delete data
Advantages of AJAX & API
- Faster websites
- No full page reload
- Dynamic content
- Better user experience
π My AJAX & API Project
π Live Project Link: https://thakarshivam175.github.io/Currency-Converter/ https://thakarshivam175.github.io/Weather-App-by-SHIVAM/
π Conclusion
- AJAX and API help us create modern and dynamic websites.
- AJAX β Handles background requests
- API β Provides data








