-
-
Save rickydazla/6985856 to your computer and use it in GitHub Desktop.
Campaign Monitor AJAX Popup Signup; edited for Tricky3 / Shopify, Liquid
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
<!-- 1. Take your Campaign Monitor subscribe form as generated from within your account [now iz html5]: --> | |
<form action="http://myaccount.createsend.com/a/b/c/defgh/" method="post" id="subForm"> | |
<div> | |
<label for="name">Name:</label><br> | |
<input type="text" name="cm-name" id="name"><br> | |
<label for="abcd-efgh">Email:</label><br> | |
<input type="text" name="cm-abcd-efgh" id="abcd-efgh" placeholder="Your Email Address"{% if customer %} value="{{ customer.email }}"{% endif %} required><br> | |
<input type="submit" value="Subscribe"> | |
</div> | |
</form> | |
<!-- 2. Add some JavaScript --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function () { | |
$('#subForm').submit(function (e) { | |
e.preventDefault(); | |
$.getJSON( | |
this.action + "?callback=?", | |
$(this).serialize(), | |
function (data) { | |
if (data.Status === 400) { | |
alert("Error: " + data.Message); | |
} else { // 200 | |
alert("Success: " + data.Message); | |
} | |
}); | |
}); | |
}); | |
</script> | |
<!-- 3. You have an AJAX subscribe form! --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment