title: jQuery ajax:error runs even if the response is OK 200
body: <p>I have a form which submit a form via AJAX with :remote => true. Looking at the server log and FireBug, I get the response 200 OK and it returns JSON in the form of:</p>
  
  <pre><code>{ "email": "test@test.com"}
  </code></pre>
  
  <p>then I have these two handlers:</p>
  
  <pre><code>$('#new_invitation').bind("ajax:success", function(event, data, status, xhr) {
      alert('test');
  });
  
  $('#new_invitation').bind("ajax:error", function() {
      alert('error');
  });
  </code></pre>
  
  <p>and even if I get back a 200OK, it is the error handler that fires. The only time I managed to make the success handler work was when I send a empty response with 200 in the header.</p>
  
  <p>I can't figure out why this isnt working :-S</p>
  
  <p>EDIT 1------------
  After doing these changes:</p>
  
  <pre><code>$('#new_invitation').bind("ajaxSuccess", function(event, data, status, xhr) {
      alert('test');
  });
  
  $('#new_invitation').bind("ajaxError", function(jqXHR, textStatus, errorThrown) {
  alert('error');
      console.log(jqXHR.responseText);
      console.log(textStatus.responseText);
      console.log(errorThrown.responseText);
  });
  </code></pre>
  
  <p>I am still getting the same error. The log stuff gives me:</p>
  
  <pre><code>undefined
  my_email@test.com
  undefined
  </code></pre>
  
  <p>Here is the code for the form (standard Rails stuff):</p>
  
  <pre><code>&lt;%= form_for @shoot.invitations.new, :url=&gt;shoot_invitations_path(@shoot), :remote =&gt; true, :html =&gt; {:class =&gt; 'form-inline'} do |f| %&gt;
      &lt;%= f.text_field :email, :'placeholder' =&gt; 'ex: test@test.com' %&gt;
      &lt;%= f.text_field :role, :'placeholder' =&gt; 'ex: Photographer' %&gt;
      &lt;%= f.submit "Invite", :class =&gt; 'btn btn-success' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>EDIT 2 ---------</p>
  
  <p>I did a few changes and now it seems my error is a parse error. I dont understand because this is the JSON I am getting back from the server (data.responseText), which seems all good:</p>
  
  <pre><code>{"email":"zxxczxc@test.com"}
  </code></pre>
  
  <p>ANSWER ---------
  I managed to have everything work when I put :'data-type' => :json in the form options. I tried this before and it did not work because I put it in the form_tag options and not the html options... </p>