隐形reCaptcha AJAX通话

隐形reCaptcha AJAX通话,第1张

隐形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>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4945409.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存