Created
September 25, 2017 04:43
-
-
Save katrina376/3454005dd2c7df5e157681c634590961 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$('#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