Not sure why I'm getting an Uncaught SyntaxError: Unexpected end of input error on this, to be honest I have used this snippet in many places before and never had this issue? I obviously am just code blind this afternoon!
<!-- jquery and bootstrap -->
<script src="js/libs.min.js?t=1494075642"></script>
<script src="js/template.js?t=1494075642"></script>
<script>
// =======================
// SUBMIT TO MAILCHIMP
// =======================
$(document).ready( function () {
var action = "https://<<client_name>>.us13.list-manage.com/subscribe/post-json?u=207e8e8eebc7ed702d92e7928";
var form = $('.mailchimp');
if ( form.length > 0 ) {
$('.mailchimp button[type="submit"]').on('click', function(e) {
e.preventDefault();
form = $(this).closest(".mailchimp");
register(form);
});
}
function register(form) {
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
cache : false,
dataType : 'json',
contentType: "application/json; charset=utf-8",
error : function(err) {
alert("Could not connect to the registration server. Please try again later.");
},
success : function(data) {
if (data.result != "success") {
$('#success').addClass("alert-danger").toggle().find("p").text(data.msg);
$('#mailchimpModal').modal('show');
$form.reset();
} else {
$('#success').addClass("alert-success").toggle().find("p").text(data.msg);
$('#mailchimpModal').modal('show');
$form.reset();
}
}
})
}
</script>