Created
May 17, 2019 16:23
-
-
Save Chanutg/075a4085bd05a49397f070d37adacf39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userAddress = document.getElementById("address"); | |
userAddress.value = "MonAdresse"; | |
var form = document.querySelector("form"); | |
form.addEventListener("submit", function (e) { | |
const req = new XMLHttpRequest(); | |
const amount = 50; | |
req.open('POST', 'http://localhost:3000/transactions/sendtx', false); | |
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
req.send("to="+userAddress.value+"&amount="+amount); | |
if (req.status === 200) { | |
console.log("Réponse reçue: %s", req.responseText); | |
} else { | |
console.log("Status de la réponse: %d (%s)", req.status, req.statusText); | |
} | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment