Last active
February 20, 2017 16:39
-
-
Save timramseyjr/daf47280c518f6790e5d0d020c85d4af to your computer and use it in GitHub Desktop.
Alternative to the CC Embed which doesn't error handle correctly for me
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
<script> | |
$(document).ready(function() { | |
$("#ctct_signup").submit(function(e) { | |
var formData = $("#ctct_signup").serialize(); | |
$.ajax({ | |
type : 'POST', | |
url : 'https://visitor2.constantcontact.com/api/signup', | |
data : formData, | |
dataType : 'json', | |
success: function(data){ | |
$("#ctct-messages").html("<p>Thank you for joining our mailing list!</p>"); | |
}, | |
error: function(response) { | |
var respText = JSON.parse(response.responseText); | |
$("#ctct-messages").empty(); | |
$.each(respText.offenders, function(i,obj){ | |
$("#ctct-messages").append("<p>" + obj.err + "</p>"); | |
}); | |
//$("#ctct-messages").html("<p>" + respText.offenders[0].err + "</p>"); | |
}); | |
e.preventDefault(); | |
}); | |
}); | |
</script> | |
<div id="ctct-messages"></div> | |
<form id="ctct_signup" action="https://visitor2.constantcontact.com/api/signup" method="post"> | |
<p>Join our email list to receive updates and specials!</p> | |
<input name="email" type="email" placeholder="Email" size="30" required> | |
<br/><br/> | |
<input name="first_name" placeholder="First name" size="30"><br/><br/> | |
<input type="hidden" name="ca" value="your-ca-value"> | |
<input type="submit"> | |
</form> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment