Skip to content

Instantly share code, notes, and snippets.

@SamWM
Created March 15, 2010 16:52
Show Gist options
  • Save SamWM/333037 to your computer and use it in GitHub Desktop.
Save SamWM/333037 to your computer and use it in GitHub Desktop.
Use AJAX to submit a form with jQuery
function AjaxForm() {
$("form.ajaxform").submit(
function(e) {
e.preventDefault();
var dataString = $(this).serialize();
var method = this.method.toUpperCase();
var action = this.action;
$.ajax({
type: method,
url: action,
data: dataString,
success: function(response) {
alert(response);
}
});
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment