title: Submit form with jquery, ajax, can't get success callback
body: <p>Alright, I'm pretty close on this, but I need a bit of help getting over the hump. I'm trying to submit a form via AJAX, in a rails app, which sends an email, and then executes some code on success. When I hit enter on my form, the AJAX is working, because I'm getting the email. However, the success code isn't running (nor the error for that matter). I also tried 'complete:' but that didn't work, so I suspect it may be some problem with the default form behavior? Ideas?</p>
  
  <p>Here is the ajax:</p>
  
  <pre><code>// AJAX Function to submit email form without refreshing page
  $("#contact_me").submit(function(){
      var dataSet = $(this).serialize();
      $.ajax({
          type: "POST",
          url: $(this).attr("action"),
          data: dataSet,
          success: function(){
              alert("Sent!");
          },
          error: function(){
              alert("Something went wrong!");
          }
      });
  
      return false;
  })
  </code></pre>
  
  <p>And the rails action which it calls:</p>
  
  <pre><code>def email_me
      name = params[:name]
      email = params[:email]
      content = params[:text]
  
      ContactMailer.first_contact(name, email, content).deliver
  
      head :ok
  end
  </code></pre>
  
  <p>Also, the form itself</p>
  
  <pre><code>&lt;%= form_tag({controller: "main", action: "email_me"}, id: "contact_me", remote: "true") do %&gt;
      &lt;div&gt;
          &lt;p&gt;&lt;%= label_tag(:name, "Name") %&gt;
          &lt;%= text_field_tag(:name) %&gt;&lt;/p&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;p&gt;&lt;%= label_tag(:email, "Email") %&gt;
          &lt;%= email_field(:user, :email) %&gt;&lt;/p&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;p&gt;&lt;%= label_tag(:text, "What's on your mind?") %&gt;&lt;/p&gt;
          &lt;%= text_area_tag(:text)%&gt;
      &lt;/div&gt;
  
      &lt;%= submit_tag("Say Hello!")%&gt;
  &lt;% end %&gt;
  </code></pre>