$(document).ready(function(){
var $form = $('form');
var posting;
var divCargando = $(".cargando");
var divOkay = $(".okay");
var url = '/echo/json/';
var datos;
$form.on('submit', function(e){
e.preventDefault();
//Se muestra el cargando antes de enviar.
mostrarLoading();
var emailValue = $form.find('#email').val();
datos = {json: JSON.stringify({email: emailValue})}
posting = $.post(url, datos);
posting.done(terminoEnvio);
posting.fail(errorEnvio);
});
function terminoEnvio(result){
//esperar 2 segundos despues de que se reciba la respuesta
setTimeout(function(){
ocultarLoading();
mostrarOkay();
//esperar 2 segundos antes de ocultar el okay
setTimeout(ocultarOkay, 2000);
}, 2000);
}
function errorEnvio(error){
alert('ocurrio un error');
console.error(error);
}
function mostrarLoading(){
divCargando.show("slow");
}
function ocultarLoading(){
divCargando.hide("slow");
}
function mostrarOkay(){
divOkay.show('slow');
}
function ocultarOkay(){
divOkay.hide('slow');
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.