Currently I use @skube method to submit mailchimp form. I can successfully setup and its really work. But I want to get the mailchimp error message in my site.
Like: While someone already subscribe or fake email provided, or invalid email etc that mailchimp provide.
Here is the code that @skube provided.
html code:
<form class="myform" action="http://XXXXXXXXXlist-manage2.com/subscribe/post" method="POST">
<input type="hidden" name="u" value="XXXXXXXXXXXXXXXX">
<input type="hidden" name="id" value="XXXXXXXXX">
<input class="input" type="text" value="" name="MERGE1" placeholder="First Name" required>
<input type="submit" value="Send" name="submit" id="mc-embedded-subscribe">
</form>
ajax code
$('.myform').submit(function(e) {
var $this = $(this);
$.ajax({
type: "GET", // GET & url for json slightly different
url: "http://XXXXXXXX.list-manage2.com/subscribe/post-json?c=?",
data: $this.serialize(),
dataType : 'json',
contentType: "application/json; charset=utf-8",
error : function(err) { alert("Could not connect to the registration server."); },
success : function(data) {
if (data.result != "success") {
// Something went wrong, parse data.msg string and display message
} else {
// It worked, so hide form and display thank-you message.
}
}
});
return false;
});
I searched about this but didn't find any valid documentation. I find a a github code but I can't make it work. Here is the github link
Hope someone help me.
Note: I tried using old api code method that exists but mailchimp suggest to not use that. They already release 3.0 version of API