title: How to get data from response of event ajax:error in Rails 5.1
body: <p>Iam building a form in Rails. I want to submit it by ajax, so I setted <code>remote: true</code></p>
  
  <pre><code>&lt;%= form_for @post, html: { multipart: true }, remote: true  do |f| %&gt;
      ...
  &lt;%= end %&gt;
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>def create
      @post = Post.new(post_param)
  
      respond_to do |format|
         if @post.save
            format.html { redirect_to @post, notice: 'Post was successfully created.' }
            format.json { render :show, status: :created, location: @post }
         else
            format.html { render json: @post.errors, status: 400 }
            format.json { render json: @post.errors, status: 400 }
        end
      end
  end
  </code></pre>
  
  <p>In form on view</p>
  
  <pre><code>$('#new_post').on('ajax:success', function(data) {
      console.log(data);
  }).on('ajax:error', function(evt, xhr, status, error) {
      console.log(xhr);
  });
  </code></pre>
  
  <p>But in event 'ajax:error', I can't parse to get data about validation errors of post. All params 'xhr', 'status', 'error' both equal undefined.</p>
  
  <p>How to parse response in 'ajax:error' to get data about validation errors ?</p>