admin管理员组

文章数量:1320611

I am trying to implement Google recaptcha in a form. The form issues an HTTP post request to a server where it sends the for data as a JSON object.

I added Google reCAPTCHA just before the form submit button with the following div tag:

     <div class="g-recaptcha" data-sitekey="{SITE_KEY}"></div>

Also I added the required JavaScript file in the head tag:

 <script src='.js'></script>

Now the submit button issues a request to a JavaScript function as follows: hence I am using Angular JS

  $scope.issueVideoUploadRequest = function () {

    var requestVideoUploadParameters = {
        videoSource: $scope.videoSource,
        title: $scope.title,
        description: $scope.description,
        videoLanguage: $scope.language,
        tagsList: $scope.tagsList
    };
    $http({
        method: "POST",
        dataType: "json",
        data: requestVideoUploadParameters,
        url: 'http://localhost:8080/OampSeniorProjectV2/rs/content/requestUploadForm'
    }).success(function (response, status, headers) {
        $scope.alertMessageVideoRequest = response;
        alert(response);
    }).error(function (response, status, headers, config) {
        $scope.reloadPage();
    });
};

The form is submitted to a REST services.

The question is, where to find the g-recaptcha-response parameter so I send it back to the server along with the form JSON object? As I need this response value to perform the server side user verification.

I was following the documentation posted here

I am trying to implement Google recaptcha in a form. The form issues an HTTP post request to a server where it sends the for data as a JSON object.

I added Google reCAPTCHA just before the form submit button with the following div tag:

     <div class="g-recaptcha" data-sitekey="{SITE_KEY}"></div>

Also I added the required JavaScript file in the head tag:

 <script src='https://www.google./recaptcha/api.js'></script>

Now the submit button issues a request to a JavaScript function as follows: hence I am using Angular JS

  $scope.issueVideoUploadRequest = function () {

    var requestVideoUploadParameters = {
        videoSource: $scope.videoSource,
        title: $scope.title,
        description: $scope.description,
        videoLanguage: $scope.language,
        tagsList: $scope.tagsList
    };
    $http({
        method: "POST",
        dataType: "json",
        data: requestVideoUploadParameters,
        url: 'http://localhost:8080/OampSeniorProjectV2/rs/content/requestUploadForm'
    }).success(function (response, status, headers) {
        $scope.alertMessageVideoRequest = response;
        alert(response);
    }).error(function (response, status, headers, config) {
        $scope.reloadPage();
    });
};

The form is submitted to a REST services.

The question is, where to find the g-recaptcha-response parameter so I send it back to the server along with the form JSON object? As I need this response value to perform the server side user verification.

I was following the documentation posted here

Share Improve this question asked May 16, 2015 at 16:32 Ali KhalilAli Khalil 931 gold badge2 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

grecaptcha.getResponse(widget_id);

This will give you the response of the recaptcha. Use this in your form submit function if you're using Angular.

本文标签: