Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var order_now = document.getElementById("order_now");
- var delivery_time = document.getElementById("delivery_time").value;
- var delivery_addr = document.getElementById("delivery_addr").value;
- order_now.addEventListener("click", function () {
- orderReq = new XMLHttpRequest();
- // var url = "submitOrder/";
- var url = "submitOrder?data=" + encodeURIComponent(JSON.stringify({"email": "hey@mail.com", "password": "101010"}));
- orderReq.open("GET", url, true);
- orderReq.setRequestHeader("Content-type", "application/json");
- orderReq.onreadystatechange = function () {
- if (orderReq.readyState === 4 && orderReq.status === 200) {
- var json = JSON.parse(orderReq.responseText);
- console.log(json.email + ", " + json.name)
- }
- };
- // var data = JSON.stringify({"email": "abc", "name": "LaraCroft"});
- orderReq.send("abc");
- });
- // Sending a receiving data in JSON format using GET method
- //
- // var order_now = document.getElementById("order_now");
- // order_now.addEventListener("click", function () {
- // var xhr = new XMLHttpRequest();
- // var url = "submitOrder?data=" + encodeURIComponent(JSON.stringify({"email": "hey@mail.com", "password": "101010"}));
- // xhr.open("GET", url, true);
- // xhr.setRequestHeader("Content-Type", "application/json");
- // xhr.onreadystatechange = function () {
- // if (xhr.readyState === 4 && xhr.status === 200) {
- // var json = JSON.parse(xhr.responseText);
- // console.log(json.email + ", " + json.password);
- // }
- // };
- // xhr.send();
- // };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement