Created
October 18, 2013 19:07
-
-
Save tylerpearson/7046528 to your computer and use it in GitHub Desktop.
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
| // <form class="small-signup js-ngp-form" action="https://api.myngp.com/v2/Forms/-22033861227691015168" method="post" target="_blank"> | |
| // <input id="Version" name="Version" type="hidden" value="AAAAA3iOF2A=" /> | |
| // <input id="id" name="id" type="hidden" value="-22033823117691015168" /> | |
| // <input id="ObfuscatedMailingId" name="ObfuscatedMailingId" type="hidden" value="" /> | |
| // <input id="TenantName" name="TenantName" type="hidden" value="lfjeld" /> | |
| // <input id="SourceCodeIds" name="SourceCodeIds" type="hidden" value="" /> | |
| // <input id="MarketSource" name="MarketSource" type="hidden" value="" /> | |
| // <input id="formType" name="formType" type="hidden" value="SignupForm" /> | |
| // <input type="email" placeholder="Email" class="email input-text" name='EmailAddress'> | |
| // <div class="clearFix"> | |
| // <input type="text" placeholder="Zip code" class="zip input-text" name='PostalCode'> | |
| // <input type="submit" value="Submit" class="submit"> | |
| // </div> | |
| // </form> | |
| (function($) { | |
| 'use strict'; | |
| // grab form id from URL (https://act.myngp.com/Forms/-2203386117123015168) | |
| // e.g. "-2203386112341015168" | |
| var NGPformId = "-220338611769235168", | |
| $NGPform = $('.js-ngp-form'), | |
| share = function(message) { | |
| if (typeof console == "object") { | |
| console.log(message); | |
| } | |
| }; | |
| $NGPform.on('submit', function(e) { | |
| var $this = $(this); | |
| e.preventDefault(); | |
| $.post("https://api.myngp.com/v2/Forms/" + NGPformId, $this.serialize()) | |
| .done(function(data) { | |
| if (!data.errors.length) { | |
| $this.html('<p class="ngp-success">Thanks for signing up!</p>'); | |
| } else { | |
| var errorMessage = "Whoops! There were a few errors submitting the form. "; | |
| errors = data.errors, | |
| $.each(errors, function(index, value) { | |
| errorMessage += "\n -"; | |
| errorMessage += value.text; | |
| }); | |
| alert(errorMessage); | |
| } | |
| share('NGP form was submitted successfully.'); | |
| }) | |
| .fail(function() { | |
| alert('There was an error submitting this form!'); | |
| }) | |
| .always(function() { | |
| share('NGP form was submitted.'); | |
| }); | |
| }); | |
| }(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment