title: How to handle google recaptcha with jquery?
body: <p>i need a little info on google recaptcha. I want to grab the value of "g-recaptcha-response" that compares in the captcha.php file i inserted below in my jquery file and then send it to the captcha.php file using jquery $.post() method. I apologize if this is duplicate but i really cannot find someone with my same problem ;)</p>
  
  <p>THE HTML</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="generator" content="AlterVista - Editor HTML"/&gt;
      &lt;script src='https://www.google.com/recaptcha/api.js'&gt;&lt;/script&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="handle_spam.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div class="g-recaptcha" data-sitekey="6Lf8LxIUAAAAALg93pw24l53KTeqrIwl7kUY-opk"&gt;&lt;/div&gt;
      &lt;button id="go"&gt;Register&lt;/button&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>THE PHP</p>
  
  <pre><code>&lt;?php
      $captcha=$_POST['g-recaptcha-response'];
      echo $captcha;       
      if(!$captcha){
          echo 'You must verify yourself';
          exit;
      }
      $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Lf8LxIUAAAAACB9iqeOermR-rPOW0zcWRfoetBO&amp;response=".$captcha."&amp;remoteip=".$_SERVER['REMOTE_ADDR']);
      if($response.success==false)
      {
          echo 'abort_all';
      }else
      {
          echo 'success';
      }
  ?&gt;
  </code></pre>
  
  <p>THE JS</p>
  
  <pre><code>$(document).ready(function(){
      $('#go').click(function(){
          send=$('')
          $.post('captcha.php',function(data){
              alert(data);
          });
      });
  });
  </code></pre>