Go Back   CodingForums.com > :: Server side development > Ruby & Ruby On Rails

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-29-2012, 09:06 PM   PM User | #1
akvarel
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
akvarel is an unknown quantity at this point
Validation messages and $.parseJSON(xhr.responseText).errors

Hello!
I try to catch a validation message with a
Code:
`$.parseJSON(xhr.responseText).errors`
but an allert message hows me "undefined" and I dont understand why.

hier are my validations:


Code:
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:


Code:
format.json{ render json: {error: @upload.errors.full_messages}, :status =>422}
and javascript for that:

Code:
$('#fileupload').fileupload({       
    
    
            error: function(xhr){
              var errors = $.parseJSON(xhr.responseText).errors
              alert(errors)         
            }
                  });
Thanks in advanced
akvarel is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:55 AM.


Advertisement
Log in to turn off these ads.