Javascript google invisible reCaptcha服务器端验证失败

Javascript google invisible reCaptcha服务器端验证失败,javascript,angularjs,cors,recaptcha,invisible-recaptcha,Javascript,Angularjs,Cors,Recaptcha,Invisible Recaptcha,我已经在我的应用程序中集成了不可见的reCaptcha,客户端响应是解决图像挑战的一部分。然后我调用一个角度函数,使用下面的代码验证服务器端的用户响应。其中onloginSubmit(令牌)是成功回调 <button id="btnLogin" ng-disabled="loginForm.$invalid" class="g-recaptcha primarybtn margin-left-zero form-contro

我已经在我的应用程序中集成了不可见的reCaptcha,客户端响应是解决图像挑战的一部分。然后我调用一个角度函数,使用下面的代码验证服务器端的用户响应。其中onloginSubmit(令牌)是成功回调

<button id="btnLogin" ng-disabled="loginForm.$invalid" 
                                class="g-recaptcha primarybtn margin-left-zero form-control-input"
                                data-sitekey="{{public_key}}"
                                data-callback='onloginSubmit'>{{'label_login' |
                                translate}}</button>

<script>
   function onloginSubmit(token) {
       angular.element(document.getElementById('loginForm')).scope().verifyReCaptcha(token);
   };
 </script>
当我点击api服务时。我得到下面的错误

Failed to load https://www.google.com/recaptcha/api/siteverify: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 405.
我找不到关于这个问题的更多文档

我做错了什么?如果有任何错误,recaptcha不会出现,并且我使用的登录按钮无法响应

在请求中,我将该方法称为Post,该方法作为选项过度使用,并且我发送的请求有效负载不存在。这是我在“网络”选项卡中看到的

请求URL:https://www.google.com/recaptcha/api/siteverify
请求方法:选项
状态代码:405
远程地址:10.120.118.50:8080

推荐人政策:降级时不推荐推荐人

大多数事情你做得很好。应用程序中需要的一件事是与外部域通信,以便可以包含HTTP头内容类型为include a JSONP格式

 $http({
      headers: {
        'Accept': 'application/json,text/plain',
        'Content-Type': 'application/jsonp;application/x-www-form-urlencoded;charset=utf-8;',
      },
      url: $scope.verifyReCaptchaURL,
      method: 'POST',
      data: captchaData
    }).success(function (data) {
         console.log("success");
         $scope.login();
    }).error(function (data) {
         console.log("error");
         $window.location.reload(true);
    });
 $http({
      headers: {
        'Accept': 'application/json,text/plain',
        'Content-Type': 'application/jsonp;application/x-www-form-urlencoded;charset=utf-8;',
      },
      url: $scope.verifyReCaptchaURL,
      method: 'POST',
      data: captchaData
    }).success(function (data) {
         console.log("success");
         $scope.login();
    }).error(function (data) {
         console.log("error");
         $window.location.reload(true);
    });