Created
October 5, 2011 14:14
-
-
Save oddieis/1264527 to your computer and use it in GitHub Desktop.
jquery popup pt 2
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
<script> | |
$(document).ready(function(){ | |
showPopup('form'); | |
$('div.popup form.marketo-form').submit(function() { | |
var data = {}; | |
$(this).find('input').add('select').add('textarea').each(function() { | |
data[$(this).attr('name')] = $(this).val(); | |
}); | |
var url = $(this).attr('action') || window.location.href; | |
var after_submit = function(data, textStatus, jqXHR) { | |
if (data.hasOwnProperty('ok') && data.ok == true) { | |
showPopup('thankyou'); | |
} else { | |
$('div.popup input[type="submit"]').removeAttr('disabled'); | |
$('div.popup span.subbody').empty().append('Oops! Please try again.').addClass('error-message'); | |
} | |
} | |
jQuery.post(url, data, after_submit, 'json'); | |
$(this).find('input[type="submit"]').attr('disabled', 'disabled'); | |
return false; | |
}); | |
$('a.twitter').click(function() { | |
if (window.location.search == "") | |
sep = '?'; | |
else | |
sep = '&'; | |
jQuery.ajax(window.location.href + sep + 'goto=twitter'); | |
closePopup(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a neat little jquery popup as spotted on one of the 10gen.com presentation pages.
it was used to collect survey data, but the UX was clean, smooth and worth keeping a track of. This sits as code on the page below part 1 link to the js file.(pt 1 = link, pt 2 = script tags).