37 lines
1 KiB
HTML
37 lines
1 KiB
HTML
<script>
|
|
function process () {
|
|
// (A) GET FORM DATA
|
|
var form = document.getElementById("my-form");
|
|
var data = new FormData(form);
|
|
|
|
// (B) AJAX SEND FORM
|
|
// NOTE: USE HTTP://. NOT FILE://.
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("POST", "https://n8n.tfcconnection.org/webhook-test/7a23cff5-daa4-4af7-aa64-684185c310e8");
|
|
xhr.onload = function () {
|
|
console.log(this.response);
|
|
form.reset(); // RESET FORM
|
|
};
|
|
xhr.send(data);
|
|
|
|
// (C) STOP DEFAULT FORM SUBMIT/PAGE RELOAD
|
|
return false;
|
|
}
|
|
</script>
|
|
|
|
<form id="my-form" action="https://n8n.tfcconnection.org/webhook-test/7a23cff5-daa4-4af7-aa64-684185c310e8" method="POST" onsubmit="return process()">
|
|
<div>
|
|
<label for="say">What greeting do you want to say?</label>
|
|
<input name="say" id="say" value="Hi" />
|
|
</div>
|
|
<div>
|
|
<label for="to">Who do you want to say it to?</label>
|
|
<input name="to" id="to" value="Mom" />
|
|
</div>
|
|
<div>
|
|
<button>Send my greetings</button>
|
|
</div>
|
|
</form>
|
|
</form>
|
|
|