Skip to content

Instantly share code, notes, and snippets.

@FabianSchmick
Last active June 7, 2018 06:22
Show Gist options
  • Save FabianSchmick/65f29c1ac70d4fe05897bc2f5513ed33 to your computer and use it in GitHub Desktop.
Save FabianSchmick/65f29c1ac70d4fe05897bc2f5513ed33 to your computer and use it in GitHub Desktop.
Ajax form skeleton
$("#idForm").on('submit', function (e) {
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize()
}).done(function(data) {
console.log(data);
}).fail(function(XMLHttpRequest, textStatus, errorThrown) {
console.log('Error');
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment