Hello!

I try to catch a validation message with a
`$.parseJSON(xhr.responseText).errors` but an alert message hows me
"undefined" and I do not understand why.

hier are my validations:


validates :upload_file_name, :presence => true,
:format =>{:with =>
%r{\.(jpg)$}i,:message =>"It should be a pdf File"}

validates_uniqueness_of :upload_file_name, :message => "blabla"

validates :upload_file_size, :inclusion => {:in
=>1.megabytes..20.megabytes,:message=>"bla"}

json:


format.json{ render json: {error: @upload.errors.full_messages},
:status =>422}

and javascript for that:

$('#fileupload').fileupload({


error: function(xhr){
var errors = $.parseJSON(xhr.responseText).errors
alert(errors)
}
});

Thanks in advanced


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/2q8T4IughRYJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 29, '12 at 9:04p
activeOct 29, '12 at 9:04p
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Akvarel: 1 post

People

Translate

site design / logo © 2022 Grokbase