Skip to content

Instantly share code, notes, and snippets.

@kirs
Created November 17, 2011 11:19
Show Gist options
  • Save kirs/1372942 to your computer and use it in GitHub Desktop.
Save kirs/1372942 to your computer and use it in GitHub Desktop.
$('#new_user').submit (e) ->
e.preventDefault()
data = $(e.target).serializeArray()
$.ajax
type: "POST"
data: data
dataType: "json"
url: $(e.target).attr('action')
success: (res) ->
window.location += ""
statusCode:
422: (res) ->
errors = JSON.parse(res.responseText)
_.each(errors, (value, key)->
console.log key
console.log value[0]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment