title: Rails: "head :ok" interpreted as "ajax:error"
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4791499/jquery-doesnt-call-success-method-on-ajax-for-rails-standard-rest-delete-answ">jquery doesn’t call success method on $.ajax for rails standard REST DELETE answer</a>  </p>
  </blockquote>
  
  
  
  <p>I respond to a remote-link <em>(data-remote="true" data-type="json")</em> and output</p>
  
  <pre><code>format.json { head :ok }
  </code></pre>
  
  <p>in my Rails (3.2.6) controller, which creates this header:</p>
  
  <pre><code>Status Code:200 OK
  </code></pre>
  
  <hr>
  
  <pre><code>...
  Connection:keep-alive
  Content-Length:1
  Content-Type:application/json; charset=utf-8
  Server:thin 1.4.1 codename Chromeo
  Set-Cookie: ... path=/; HttpOnly
  X-UA-Compatible:IE=Edge
  ...
  </code></pre>
  
  <p>In my JavaScript file <strong>ajax:complete</strong> is triggered and outputs <strong>200</strong> <em>(data.status)</em>.</p>
  
  <pre><code>  $( '#myElement' ).on( 'ajax:complete', function( e, data ) {
      console.log( data.status );
    });
  </code></pre>
  
  <p><em>data</em> looks like this:</p>
  
  <pre><code> ...
   readyState: 4
   responseText: " "
   setRequestHeader: function ( name, value ) {...
   state: function () {...
   status: 200
   statusCode: function ( map ) {...
   statusText: "OK"
   ...
  </code></pre>
  
  <p><em>Looks pretty good to me...</em></p>
  
  <h2>The problem</h2>
  
  <p>Instead of <strong>ajax:success</strong>, jQuery <em>(jquery-ujs)</em> executes <strong>ajax:error</strong> and I have no idea why since no error is given.</p>
  
  <p>I have looked into alot of discussions, but this way always seemed to be the solution, not the problem. Thank you for any help!</p>