title: Submit Rails form using jQuery
body: <p>I am trying to submit a Rails form using jQuery and Ajax however it is not working and I am not sure why. I realize there is the <code>remote: true</code> to do things using AJAX but this is not enough in my case as I want to perform other jQuery actions when the submit buttons is clicked and give good feedback on the status of the action i.e success and failure. This is code I currently have the form:</p>
  
  <pre><code>&lt;%= form_for @mail, id: "mail-form", url: subscription_mail_create_recipients_path(@mail) do |f| %&gt;
  
      &lt;strong&gt;Choose the users you want to target..&lt;/strong&gt;&lt;br/&gt;
  
      &lt;%= f.check_box :target_users %&gt; Users                          
  
      &lt;div class="actions"&gt;
      &lt;a id="save-config" class="btn btn-primary purple-button"&gt;Save configuration&lt;/a&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The jQuery:</p>
  
  <pre><code>    $('#save-config').click(function(){
          $('#mail-form').submit(function() {
              var valuesToSubmit = $(this).serialize();
              console.log(valueToSubmit);
                              $.ajax({
                                  url: $(this).attr('action'), //sumbits it to the given url of the form
                                  data: valuesToSubmit,
                                  dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard
                              }).success(function(json){
                                  //act on result.
                              });
              alert("method failed");
                              return false; // prevents normal behaviour
          });
      });
  </code></pre>
  
  <p>I am trying to work off the example here <a href="https://stackoverflow.com/questions/6723334/submit-form-in-rails-3-in-a-ajax-way-with-jquery">Submit form in rails 3 in an ajax way (with jQuery)</a></p>
  
  <p>I have no submit button, is that the reason it is not working? Any help would be appreciated thanks.</p>