Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Created June 10, 2016 23:16
Show Gist options
  • Save mikekavouras/56914203254291c6e9a5bed655719c3c to your computer and use it in GitHub Desktop.
Save mikekavouras/56914203254291c6e9a5bed655719c3c to your computer and use it in GitHub Desktop.
function shirtIt(name) {
var xhr = new XMLHttpRequest();
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
alert(JSON.parse(xhr.responseText));
}
}
};
xhr.open('POST', '/'+name+, true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.send(data);
}
document.getElementById('button').addEventListener('click', function() {
var name = document.getElementById('name');
shirtIt(name);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment