Skip to content

Instantly share code, notes, and snippets.

@jblac
Created January 1, 2013 22:01
Show Gist options
  • Save jblac/4430364 to your computer and use it in GitHub Desktop.
Save jblac/4430364 to your computer and use it in GitHub Desktop.
$('form').on("submit", function(e) {
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(resp) {
var obj = $.parseJSON(resp);
if (obj.resp == 0) {
$(this).removeAlertBoxes();
$(this).alertBox(obj.err, { type: 'error'});
} else if (obj.resp == 'redirect') {
this[0].reset();
window.location = obj.redirect;
} else if (obj.resp == 'reload') {
this[0].reset();
window.location.reload();
}
}
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment