title: Read cross domain JSON response
body: <pre><code>     &lt;script&gt;
          $.ajaxSetup( {contentType: 'application/json'} );
          function submit_data(f){
            alert('submitting')
            var data_string = $(f).serialize();
            $.ajax({
                  url: "http://localhost:3000/application/1/contact_us.json?jsonpcallback=?"+data_string,
                  dataType: "jsonp",
                  type : 'post',
                  processData: false,
                  crossDomain: true,
                  contentType: "application/json",
                  jsonp: false,
                  jsonpcallback: result()
              });
          }
  
          function result(){
            alert('back in')
            alert(data)
          }
          function jsonp1300279694167(){
            alert('dhoom')
          }
        &lt;/script&gt;
  </code></pre>
  
  <p>I have script above querying across domain and posting data within a form.<br>
  Everything seems to work fine. JSON response can be seen in the firebug console. I want to process the response and display status messages accordingly to the user. How should I achieve it?</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have tried as suggested by <em>T.J. Crowder</em> but have no luck yet. The modified code is as below</p>
  
  <pre><code>function submit_data(f){
    alert('submitting')
    var data_string = $(f).serialize();
    $.ajax({
              url: "http://localhost:3000/application/1/contact_us.json?"+data_string,
              dataType: "jsonp",
              crossDomain: true,
              success: handleSuccess()
          });
  }
  
  
  
  function handleSuccess(data) {
    alert("Call completed successfully");
    alert(data);
  }
  </code></pre>
  
  <p>This does not accesses <code>data</code> and alerts <code>undefined</code>. If I try to pass it from <code>success: handleSuccess()</code> it errors and redirects with a http request.</p>
  
  <p>I am getting response from a <code>Ruby on Rails</code> application. Here is the method I am hitting </p>
  
  <pre><code>def create
      errors = ContactUsForm.validate_fields(params)
      logger.info errors.inspect
      if errors.blank?
        respond_to do |format|
          format.json {render :json =&gt; {:status =&gt; 'success'}.to_json}
        end
      else
        respond_to do |format|
          format.json {render :json =&gt; {:status =&gt; 'failure', :errors =&gt; errors}.to_json}
        end
      end
    end
  </code></pre>
  
  <p>Is there any thing that I need to configure in my rails app</p>