Created
January 28, 2017 09:02
-
-
Save eivko/fe7b5dae151b9e27158baa8e84cab088 to your computer and use it in GitHub Desktop.
Отправка AJAX-формы
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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