Skip to content

Instantly share code, notes, and snippets.

@maximilianoraul
Created December 20, 2014 13:23
Show Gist options
  • Save maximilianoraul/7ff9eef129c0156d8277 to your computer and use it in GitHub Desktop.
Save maximilianoraul/7ff9eef129c0156d8277 to your computer and use it in GitHub Desktop.
AJAX Request
<script type="text/javascript">
$('form').submit(function () {
$('form button').attr("disabled", "disabled");
$('#loading').fadeIn();
$('#msj').html('');
$.post('<?php echo Flight::base_url('contacto'); ?>', $('form').serializeArray(), function (d) {
$('#loading').fadeOut();
$('form button').removeAttr('disabled');
$('#msj').html(d.msj);
$('html, body').animate({scrollTop: $("#msj").offset().top}, 500);
if (d.status === true) {
$('form').slideUp();
} else {
$('#captcha').attr('src','<?php echo Flight::base_url('captcha'); ?>?' + Math.random());
}
}, 'json');
return false;
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment