Так что в основном это делает вызов, а затем отображает сообщение.Просто не забудьте обновить id
s в скрипте (в нижней половине) var successMessage = $('#success'); var form = $('#subForm')
.
Не тестировалось с новым обновлением CM, но у меня это сработало.
CSS
#success {display: none;}
HTML / js:
<div id="success">
<h2 class='thank-you'>Thank you for subscribing</h2>
</div>
<form id="subForm" class="js-cm-form" action="https://www.createsend.com/t/subscribeerror?description=" method="post" data-id="XXXX-XXX-XX-X">
<p>
<input placeholder="Full Name" id="fieldName" name="cm-name" type="text" />
</p><br/>
<p>
<input placeholder="Email" id="fieldEmail" class="js-cm-email-input" name="cm-fhutty-fhutty" type="email" required />
</p><br/>
<p>
<label for="fieldeihjlu">How did you hear of us?</label><br />
<select id="fieldeihjlu" name="cm-fo-eihjlu">
<option value="1985454">Word of Mouth</option>
<option value="1985450">Social Media</option>
<option value="1985451">Press</option>
<option value="1985452">Web Search</option>
<option value="1985453">Sales and Marketing Activities</option>
</select>
</p>
<p>
<input class="js-cm-submit-button" type="submit" value="Submit">
</p>
</form>
<script type="text/javascript" >
! function(e) {
var t = {};
function n(o) {
if (t[o]) return t[o].exports;
var r = t[o] = {
i: o,
l: !1,
exports: {}
};
return e[o].call(r.exports, r, r.exports, n), r.l = !0, r.exports
}
n.m = e, n.c = t, n.d = function(e, t, o) {
n.o(e, t) || Object.defineProperty(e, t, {
configurable: !1,
enumerable: !0,
get: o
})
}, n.r = function(e) {
Object.defineProperty(e, "__esModule", {
value: !0
})
}, n.n = function(e) {
var t = e && e.__esModule ? function() {
return e.default
} : function() {
return e
};
return n.d(t, "a", t), t
}, n.o = function(e, t) {
return Object.prototype.hasOwnProperty.call(e, t)
}, n.p = "", n(n.s = 1)
}([function(e, t) {
var n;
"function" != typeof(n = window.Element ? window.Element.prototype : window.HTMLElement.prototype).matches && (n.matches = n.msMatchesSelector || n.mozMatchesSelector || n.webkitMatchesSelector || function(e) {
for (var t = (this.document || this.ownerDocument).querySelectorAll(e), n = 0; t[n] && t[n] !== this;) ++n;
return Boolean(t[n])
}), "function" != typeof n.closest && (n.closest = function(e) {
for (var t = this; t && 1 === t.nodeType;) {
if (t.matches(e)) return t;
t = t.parentNode
}
return null
}),
function() {
var e, t, n, o = document.documentElement || document.body;
o.getAttribute("data-cm-hook") || (t = "submit", n = function(e) {
var t = e.target.closest(".js-cm-form");
t && (e.preventDefault ? e.preventDefault() : e.returnValue = !1, function(e, t, n) {
var o = n.querySelector(".js-cm-email-input"),
r = "email=" + encodeURIComponent(o.value) + "&data=" + encodeURIComponent(n.getAttribute("data-id")),
c = new XMLHttpRequest;
c.onreadystatechange=function(){
if (this.readyState === 4) {
if (this.status === 200) {
// Having token and new submit url we can create new request to subscribe a user.
var successMessage = $('#success');
var form = $('#subForm')
subscribeRequest = new XMLHttpRequest();
subscribeRequest.open('POST', this.responseText, true);
subscribeRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
subscribeRequest.send($("#subForm").serialize());
// On ready state call response function.
subscribeRequest.onreadystatechange = function() {
form.hide('fast');
successMessage.show('fast');
}
} else {
alert("error");
}
}
}, c.open(e, t, !0), c.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), c.send(r)
}("POST", "https://createsend.com//t/getsecuresubscribelink", t))
}, (e = o).addEventListener ? e.addEventListener(t, n) : e.attachEvent("on" + t, n), o.setAttribute("data-cm-hook", "1"))
}()
}, function(e, t, n) {
e.exports = n(0)
}]);
</script>