栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

隐形reCaptcha AJAX通话

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

隐形reCaptcha AJAX通话

您缺少

onSubmit()
回调函数。

要重新排列您的js以利用该功能,这将是您的新js块:

<script>// this block must be defined before api.js is includedfunction onSubmit(token) {    var fields = $('#contact-form').serializeArray();  // get your form data        fields.push({name: "g-recaptcha-response", value: token});// add token to post    $.ajax({        type: "POST",        url: "assets/php/contact.php",        data: fields,        dataType: 'json',        success: function(response) { if(response.status) {     $('#contact-form input').val('');     $('#contact-form textarea').val(''); } $('#response').empty().html(response.html);        }    });    grecaptcha.reset();// to reset their widget for any other tries}</script><script src="https://www.google.com/recaptcha/api.js" async defer></script><script>// this block can be defined anywhere$(function() {    $("#contact-submit").on('click',function() {        // call grecaptcha.execute, which causes recaptcha to        // do its thing and then calls onSubmit with the token        grecaptcha.execute();// does not return anything directly        return false;    });});</script>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/383496.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号