Skip to content

Instantly share code, notes, and snippets.

@oddieis
Created October 5, 2011 14:14
Show Gist options
  • Save oddieis/1264527 to your computer and use it in GitHub Desktop.
Save oddieis/1264527 to your computer and use it in GitHub Desktop.
jquery popup pt 2
<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>
@oddieis
Copy link
Author

oddieis commented Oct 5, 2011

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment