title: How to send json response from controller to jQuery and inspect it?
body: <p>I have this problem : I'm checking user email in controller and sending json successfull response if it is already taken and add css styling of input, also I need to prevent submit and add some message.</p>
  
  <p>Here is my checkemail action ( used this article - <a href="http://paydrotalks.com/posts/45-standard-json-response-for-rails-and-jquery" rel="nofollow">http://paydrotalks.com/posts/45-standard-json-response-for-rails-and-jquery</a> ):</p>
  
  <pre><code>def checkemail
    if !User.where('email = ?', params[:email]).empty?
      format.jsonr do
        render :json =&gt; { 
          :status =&gt; :ok, 
          :message =&gt; "Success!",
        }.to_json
      end
    end
  end
  </code></pre>
  
  <p>and in my routes:</p>
  
  <pre><code>         checkemail GET    /checkemail(.:format)
  
            match "/checkemail", to: 'edit_user#checkemail'
  </code></pre>
  
  <p>and my jQuery:</p>
  
  <pre><code>   $('#user_email').focusout(function() {
      $.getJSON('/checkemail', { email: $('#user_email').val() }, function(data) {
          $('#user_email').addClass("error");
        });
     });
  </code></pre>
  
  <p>my HTML input code:</p>
  
  <pre><code>     &lt;input id="user_email" name="user[email]" size="30" type="email" value=""&gt;
  </code></pre>
  
  <p>from mime_type initializers file:</p>
  
  <pre><code>    Mime::Type.register_alias "application/json", :jsonr, %w( text/x-json )
  </code></pre>
  
  <p><b>From Fiddler:</b></p>
  
  <pre><code>  Request : GET /checkemail?user@mail.com HTTP/2.0
  
    Response(RAW tab) : 
    Missing template edit_user/checkemail
  
    JSON tab is empty
  </code></pre>
  
  <p><b>QUESTIONS: How to inspect is json request sent ? How can I prevent submission form and add some message ?</b></p>