$(document).ready(function() {
   // Mostramos el loader
    $().ajaxStart(function() {
        $('#loading').show();
        $('#result').hide();
    }).ajaxStop(function() {
        $('#loading').hide();
        $('#result').fadeIn('slow');
    });
   // Enviamos el formulario
    $('#myform').submit(function() {
   // Definimos el metodo ajax, los datos
        $.ajax({
            type: 'POST',
            url: $(this).attr('action'),
            data: $(this).serialize(),
            success: function(data) {
                // Imprimimos la respuesta en el div result
                $('#result').html(data);

            }
        })
       
        return false;
    });
})  
