Ali*_*lil 3 javascript rest json recaptcha angularjs
我正在尝试在表单中实现Google recaptcha.表单向服务器发出HTTP post请求,并将数据作为JSON对象发送.
我在表单提交按钮之前添加了Google reCAPTCHA,其中包含以下div标记:
<div class="g-recaptcha" data-sitekey="{SITE_KEY}"></div>
Run Code Online (Sandbox Code Playgroud)
我还在head标签中添加了所需的JavaScript文件:
<script src='https://www.google.com/recaptcha/api.js'></script>
Run Code Online (Sandbox Code Playgroud)
现在,提交按钮向JavaScript函数发出请求,如下所示:因此我使用的是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();
});
};
Run Code Online (Sandbox Code Playgroud)
表单将提交给REST服务.
问题是,在哪里可以找到g-recaptcha-response参数,所以我将它与表单JSON对象一起发送回服务器?因为我需要这个响应值来执行服务器端用户验证.
我按照这里发布的文件
grecaptcha.getResponse(WIDGET_ID);
这将给你回收的回应.如果您使用的是Angular,请在表单提交功能中使用此功能.
归档时间: |
|
查看次数: |
3638 次 |
最近记录: |