Skip to content

Instantly share code, notes, and snippets.

@jelukas

jelukas/gist:9547235

Created Mar 14, 2014
Embed
What would you like to do?
<form method="post" class="formulario-early-suscriber" id="form-plan-anual">
<input name="email" placeholder="Escribe tu Email" type="email" required>
<input name="plan" value="anual" type="hidden">
<input name="precio" value="195 eur" type="hidden">
<button class="submit-form" data-em="button" type="submit">Avísame Cuando esté Listo</button>
</form>
<!-- Javascript Code -->
<script type="text/javascript">
$(document).ready(function() {
$('.formulario-early-suscriber').on('submit',enviar_email);
function enviar_email(ev){
ev.preventDefault();
var url = "early_suscribe.php";
var form = this;
$.ajax({
type: "POST",
url: url,
data: $(form).serialize(), // Adjuntar los campos del formulario enviado.
success: function(data){
parent = $(form).parent();
parent.find('.close-link').remove();
$(form).hide();
parent.append('<p class="alert alert-success early-suscribe-success">'+data+'</p>');
}
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment