Skip to content

Instantly share code, notes, and snippets.

@alxfv
Last active December 21, 2015 00:19
Show Gist options
  • Save alxfv/6219456 to your computer and use it in GitHub Desktop.
Save alxfv/6219456 to your computer and use it in GitHub Desktop.
$(function() {
(function() {
$('form').submit(function() {
$.ajax({
url: '/app_dev.php/users/510a702aa3d0b4f0c9dbf10b/edit',
data: $('form').serialize(),
type: 'POST',
dataType: 'json',
success: function(data, textStatus, jqXHR ) {
if (data.status == 'invalid') {
$('form img').prop('src', data.img);
$('img').insertAfter('error!');
}
else {
window.location = data.redirect;
}
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
return false;
});
})();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment