Skip to content

Instantly share code, notes, and snippets.

@eivko
Created January 28, 2017 09:02
Show Gist options
  • Save eivko/fe7b5dae151b9e27158baa8e84cab088 to your computer and use it in GitHub Desktop.
Save eivko/fe7b5dae151b9e27158baa8e84cab088 to your computer and use it in GitHub Desktop.
Отправка AJAX-формы
$(function() {
$('form').submit(function(e) {
var $form = $(this);
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize()
}).done(function() {
console.log('success');
}).fail(function() {
console.log('fail');
});
//отмена действия по умолчанию для кнопки submit
e.preventDefault();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment