XML HTTP Request
- All modern browsers support the XMLHttpRequest object to request data from a server.
- It works on the oldest browsers as well as on new ones.
- It was deprecated in ES6 but is still widely used.
JSONPlaceholder is a free online REST API that you can use whenever you need fake data.
We can see on below, the XMLHttpRequest gives the output call like below.
- The Fetch API provides an interface for fetching resources (including across the network) in an asynchronous manner.
- It returns a Promise
- It is an object which contains a single value either a Response or an Error that occurred.
- .then() tells the program what to do once Promise is completed.
- It is an open-source library for making HTTP requests.
- It works on both Browsers and Node js
- It can be included in an HTML file by using an external CDN
- It also returns promises like fetch API
Axios provides the following advantages:
- Axios performs automatic transformations and returns the data in JSON format.
- Better error handling.
- Axios has a wide range of supported browsers.
JQuery has many methods to handle asynchronous
HTTP requests. In order to use jQuery, we need to include the source file of jQuery. The
$.ajax() method is used to make the HTTP request.
The $.ajax method takes many parameters, some that are required and others that are optional. It contains two callback functions success and error to handle the response received.
Leave behind your valuable queries, suggestions in the comment section below regarding article How to Implement Repository Pattern in ASP.Net Core Web API. Also, if you think this article help to you, do not forget to share this within your developer community. Happy Coding 🙂
- How to read external JSON file in Jquery AJAX
Jayant TripathyCoder, Blogger, YouTuber
A passionate developer keep focus on learning and working on new technology.