JSFiddle - React, Tailwind, and code Playground
by otupman
HTML
<form class="myform" action="http://centralway.us7.list-manage.com/subscribe/post" method="POST">
<input type="hidden" name="u" value="84d2e06109ae0dc3c028e30c0">
<input type="hidden" name="id" value="d7b7c0d751">
<input class="input" type="text" value="" name="MERGE1" placeholder="First Name" required>
<input class="input" type="email" value="" name="EMAIL" placeholder="email" required/>
<input type="submit" value="Send" name="submit" id="mc-embedded-subscribe">
</form>
JavaScript
$('.myform').submit(function(e) {
var $this = $(this);
$.ajax({
type: "GET", // GET & url for json slightly different
url: "http://centralway.us7.list-manage.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;
});