title: In jquery How to tell what form is being submitted?
body: <p>I have ajax calls made like this:</p>
  
  <pre><code>$('.register a').click(register);
  </code></pre>
  
  <p>The register function:</p>
  
  <pre><code>function register(e){
      e.preventDefault();
      var params = $('.register').serialize();
      Api.callApi(
          "/api/authkey/create_user",
          params,
          //success!
          function(response){
              settooltip(response.msg[0])
              // GA
              _gaq.push(['_trackPageview', '/registered']);
              _gaq.push(['_trackEvent', 'register', 'public']);
          },
          //error
          function(response){
              settooltip(response.msg[0])
          }
      );
  }
  </code></pre>
  
  <p>Sometimes ajax responds with errors. I try to show theese arrows next the field that has the error(that's what the settooltipc–function does). However, the api only responds with the name of the field that has the error, and sometimes, there are more fields than one with the same name. This means I can't know what field I should apply the error message to.</p>
  
  <p>My Idea for how to solve this is by setting an ID to the form that was latest submitted. However, I would like to do this within the register-function. I could use "this" if someone actually clicks the .register a, but if they use enter, "this" contain the window-element instead. Is this a good approach? In that case, how can I tell what form is being submitted?</p>