XMLHttpRequest is an API in the form of an object whose methods transfer data between a web browser and a web server. The object is provided by the browser's JavaScript environment.
-
Open
index.html
and click on particular operations -
Refer
console
for details of both working and code
src
Burgers
- (Requires local database)
GitHubAPI
- (Requires GitHub API)
- Get one field
- Get array
Local
- (Burgers API alternative)
- MessagesAPI
db1.json
db2.json
index.html
- Create
- Read
- Update
- Delete
function gitUser() {
var xhr = new XMLHttpRequest();
var method = "GET";
var URL = "https://api.github.com/users/pratikkabade";
xhr.open(method, URL, true);
xhr.send();
xhr.onload = function () {
if (xhr.status == 200) {
const data = JSON.parse(xhr.response);
console.log("success");
const p = document.createElement("li");
p.innerHTML = data.bio;
document.getElementById("output").appendChild(p);
}
};
}