Skip to content

Instantly share code, notes, and snippets.

@Chanutg
Created May 17, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chanutg/075a4085bd05a49397f070d37adacf39 to your computer and use it in GitHub Desktop.
Save Chanutg/075a4085bd05a49397f070d37adacf39 to your computer and use it in GitHub Desktop.
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