Skip to content

Instantly share code, notes, and snippets.

@mosinski
Created February 3, 2014 22:12
Show Gist options
  • Save mosinski/8793493 to your computer and use it in GitHub Desktop.
Save mosinski/8793493 to your computer and use it in GitHub Desktop.
/* ==================================================
AJAX Register Form
================================================== */
jQuery(function($){
$("form#sign_up_user").submit(function(e){
e.preventDefault();
var user_info = $(this).serialize();
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: user_info,
success: function(json){
window.location.href = "/user_steps/hello?";
},
error: function(json) {
$("#register_errors").html("");
$("#register_errors").show();
$.each(json.responseJSON.errors, function( i, l ){
if(i == "password") {
i = "Hasło"
}
else if(i == "email") {
i = "E-mail"
}
$("#register_errors").append("<b>"+i+"</b> "+l+"<br>");
});
},
dataType: "json"
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment