title: Invisible ReCaptcha with jQuery ajax
body: <p>I am trying to implement the newest ReCaptcha (aka "invisible" ReCaptcha) within an form using jQuery and an "ajax" request.<br />
  ReCaptcha documentation: <a href="https://developers.google.com/recaptcha/docs/invisible" rel="noreferrer">https://developers.google.com/recaptcha/docs/invisible</a></p>
  
  <p>My form:</p>
  
  <pre><code>&lt;form id="myForm" &gt;
      &lt;input type="email" name="email" /&gt;&lt;br /&gt;
      &lt;input type="password" name="password" /&gt;&lt;br/&gt;
      &lt;!--&lt;input type="submit" value="log in" /&gt;--&gt;
      &lt;button class="g-recaptcha" data-sitekey="6LdK..." data-callback="onSubmit"&gt;log in&lt;/button&gt;
  &lt;/form&gt;
  &lt;div id="status"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>My javascript (jQuery):</p>
  
  <pre><code>&lt;script&gt;
  
      function onSubmit(token){
          document.getElementById("myForm").submit();
      }
  
      $(document).ready(function(){
  
          $("#myForm").submit(function(event){
              event.preventDefault();
              var datas = $("#myForm").serialize();
              $.ajax({
                  type: "POST",
                  url: "test.php",
                  data: datas,
                  dataType: "json",
                      beforeSend: function(){
                          $("#status").html("logging in...");
                      },
                      success: function(response){
                          $("#status").html(response.text);
                          if(response.type=="success"){
                              window.location.replace("/myaccount");
                          }
                      },
                      error: function(){
                          $("#status").html("Failed.");
                      }
              });
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>ReCaptcha requires to set a "data-callback", which I am not sure how to bind with my already existing ".submit(function(event)" function.<br />
  My "onSubmit()" trick did not work, it ignores the "ajax" and refreshes the page.<br />
  <br />How do I send the "g-recaptcha-response" value within my "datas" variable to POST it to test.php?</p>