Skip to content

Instantly share code, notes, and snippets.

@dvidsilva
Created October 20, 2015 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvidsilva/ded7d5f5dee85d5ceb6a to your computer and use it in GitHub Desktop.
Save dvidsilva/ded7d5f5dee85d5ceb6a to your computer and use it in GitHub Desktop.
AJAX submit form with Jquery
$(document).ready(function() {
$('form').submit(function(event) {
event.preventDefault();
var formData = $(this).serialize();
$.ajax({
type : 'POST',
url : $(this).attr('action'),
data : formData,
dataType : 'json',
encode : true
}).done(function(data) {
console.log(data);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment