Skip to content

Instantly share code, notes, and snippets.

@katrina376
Created September 25, 2017 04:43
Show Gist options
  • Save katrina376/3454005dd2c7df5e157681c634590961 to your computer and use it in GitHub Desktop.
Save katrina376/3454005dd2c7df5e157681c634590961 to your computer and use it in GitHub Desktop.
$('#dat-form').onsubmit = function (ev) {
ev.preventDefault();
dat_value = ev.target.elements.dat_field_name.value
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
dat_action(xhr.responseText);
} else {
alert('Error: ' + xhr.status);
}
}
}
xhr.open('GET', '/dat-api?dat_field_name=' + dat_value, true);
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment