我想在我的webservice中使用recaptcha . 我加

.g-recaptcha(data-sitekey='mysitekey')

并使这样的JavaScript

if (typeof(grecaptcha) != 'undefined'){
  if (grecaptcha.getResponse() == ""){
    alert("error")
    return;
  }
}

$(function chk_recaptcha(){
  if (!isset($_POST['g-recaptcha-response']))return false;

  $gg_response = trim($_POST['g-recaptcha-response']);
  if ($gg_response == "") return false;

  $url = 'https://www.google.com/recaptcha/api/siteverify';
  $data = array('secret' = 'mysecret key',
                'response' = $gg_response,
                'remoteip' = $_SERVER['REMOTE_ADDR']);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, sizeof($data));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch);
  curl_closr($ch);

  $obj = json_decode($result);
  if ($obj = success ==false){
    alert("error!"); 
    history.go(-1);
  }
  return true;
});

但当我忽略检查recaptcha时,它仍然没有警报继续 .

我怎么解决这个问题?