Skip to content

Instantly share code, notes, and snippets.

@pelargir
Created June 16, 2010 19:45
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 pelargir/441161 to your computer and use it in GitHub Desktop.
Save pelargir/441161 to your computer and use it in GitHub Desktop.
$('#my_form').submit(function(event) {
$.ajax({
type: 'POST',
dataType: 'json',
data: $(event.target).serialize(),
url: event.target.action,
success: function(json) {
if (json['success'] == true) {
window.location = json['redirect_to'];
} else {
$('#form_errors').html(json['errors']);
}
},
error: function(request, error) {
alert(error);
}
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment