1// Sending and receiving data in JSON format using POST method
2//
3var xhr = new XMLHttpRequest();
4var url = "url";
5xhr.open("POST", url, true);
6xhr.setRequestHeader("Content-Type", "application/json");
7xhr.onreadystatechange = function () {
8 if (xhr.readyState === 4 && xhr.status === 200) {
9 var json = JSON.parse(xhr.responseText);
10 console.log(json.email + ", " + json.password);
11 }
12};
13var data = JSON.stringify({"email": "hey@mail.com", "password": "101010"});
14xhr.send(data);
15