Skip to content

Instantly share code, notes, and snippets.

@Inviz
Created January 2, 2018 23:33
Show Gist options
  • Save Inviz/975bfd891523efdfcd09c77d3e0440dd to your computer and use it in GitHub Desktop.
Save Inviz/975bfd891523efdfcd09c77d3e0440dd to your computer and use it in GitHub Desktop.
var email = 'abc@cde.frg'
var xhr = new XMLHttpRequest
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
try {
var response = JSON.parse(xhr.response);
} catch (e) {
var response = {
status: xhr.status,
title: xhr.response
};
}
if (response.status != 400) {
console.log(response)
} else {
console.error(response, response.errors, response.status, response.title)
}
}
}
xhr.open('POST', '//www.narrowdesign.com/scripts/mailchimp.php')
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send('email=' + email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment