title: reCAPTCHA couldn't find user-provided function: onloadCallback
body: <p>When I load my page, I get this error in the console</p>
  
  <p>"reCAPTCHA couldn't find user-provided function: onloadCallback"</p>
  
  <p>I have followed a tutorial from phppot for a PHP with Google Recaptcha. When I click submit without doing the recaptcha, it gives me an error saying that I need to complete it.
  However, when I do complete it, it shows my loading symbol in a never ending loop and doesn't actually send the email. I have the following codes below:</p>
  
  <pre><code>    $(document).ready(function (e){
      $("#frmContact").on('submit',(function(e){
          e.preventDefault();
          $("#mail-status").hide();
          $('#send-message').hide();
          $('#loader-icon').show();
          $.ajax({
              url: "contact.php",
              type: "POST",
              dataType:'json',
              data: {
              "name":$('input[name="name"]').val(),
              "email":$('input[name="email"]').val(),
              "phone":$('input[name="phone"]').val(),
              "content":$('textarea[name="content"]').val(),
              "g-recaptcha-response":$('textarea[id="g-recaptcha-response"]').val()},             
              success: function(response){
              $("#mail-status").show();
              $('#loader-icon').hide();
              if(response.type == "error") {
                  $('#send-message').show();
                  $("#mail-status").attr("class","error");                
              } else if(response.type == "message"){
                  $('#send-message').hide();
                  $("#mail-status").attr("class","success");                          
              }
              $("#mail-status").html(response.text);  
              },
              error: function(){} 
          });
      }));
  });
  </code></pre>
  
  <p>is in my  section on top of my contactus.php page.</p>
  
  <p>Then I have the following for my contact.php page:</p>
  
  <pre><code> if($_POST)
  </code></pre>
  
  <p>{</p>
  
  <pre><code>$user_name      = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
  $user_email     = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
  $user_phone     = filter_var($_POST["phone"], FILTER_SANITIZE_STRING);
  $content   = filter_var($_POST["content"], FILTER_SANITIZE_STRING);
  
  if(empty($user_name)) {
      $empty[] = "&lt;b&gt;Name&lt;/b&gt;";       
  }
  if(empty($user_email)) {
      $empty[] = "&lt;b&gt;Email&lt;/b&gt;";
  }
  if(empty($user_phone)) {
      $empty[] = "&lt;b&gt;Phone Number&lt;/b&gt;";
  }   
  if(empty($content)) {
      $empty[] = "&lt;b&gt;Comments&lt;/b&gt;";
  }
  
  if(!empty($empty)) {
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; implode(", ",$empty) . ' Required!'));
      die($output);
  }
  
  if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){ //email validation
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; '&lt;b&gt;'.$user_email.'&lt;/b&gt; is an invalid Email, please correct it.'));
      die($output);
  }
  
  //reCAPTCHA validation
  if (isset($_POST['g-recaptcha-response'])) {
  
      require('component/recaptcha/src/autoload.php');        
  
      $recaptcha = new \ReCaptcha\ReCaptcha(SECRET_KEY, new \ReCaptcha\RequestMethod\SocketPost());
  
      $resp = $recaptcha-&gt;verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
  
        if (!$resp-&gt;isSuccess()) {
              $output = json_encode(array('type'=&gt;'error', 'text' =&gt; '&lt;b&gt;Captcha&lt;/b&gt; Validation Required!'));
              die($output);               
        } 
  }
  
  $toEmail = "member@testdomain.com";
  $mailHeaders = "From: " . $user_name . "&lt;" . $user_email . "&gt;\r\n";
  if (mail($toEmail, "Contact Mail", $content, $mailHeaders)) {
      $output = json_encode(array('type'=&gt;'message', 'text' =&gt; 'Hi '.$user_name .', thank you for the comments. We will get back to you shortly.'));
      die($output);
  } else {
      $output = json_encode(array('type'=&gt;'error', 'text' =&gt; 'Unable to send email, please contact'.SENDER_EMAIL));
      die($output);
  }
  </code></pre>
  
  <p>}</p>