Skip to content

Instantly share code, notes, and snippets.

@joachimdoerr
Created November 24, 2011 20:34
Show Gist options
  • Save joachimdoerr/1392216 to your computer and use it in GitHub Desktop.
Save joachimdoerr/1392216 to your computer and use it in GitHub Desktop.
simple way for ajax-form-submit
$(document).ready(function(){
$("form").submit(function(){
var thistarget = this.target;
jQuery.ajax({
data: $(this).serialize(),
url: this.action,
type: this.method,
error: function() {
$(thistarget).html("Error: Failed to submit form!");
},
success: function(results) {
$(thistarget).html(results);
}
})
return false;
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment