Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send form with ajax
$('#id-form button[type=submit]').click(function(e){
e.preventDefault();
$(this).text('Einen moment...');
var form = jQuery(this).parents("form:first");
var dataString = form.serialize();
var formAction = form.attr('action');
$.ajax({
type: "POST",
url : formAction,
data : dataString,
success : function(data){
console.log(data);
},
error : function(data){
var errors = $.parseJSON(data.responseText);
console.log(errors);
}
},"json");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.