【问题标题】:Google Recaptcha is not working on fancybox ajax popupGoogle Recaptcha 不适用于fancybox ajax 弹出窗口
【发布时间】:2017-11-09 11:01:34
【问题描述】:

Google Recaptcha 不适用于 fancybox ajax 生成的表单。

【问题讨论】:

    标签: fancybox recaptcha fancybox-2


    【解决方案1】:

    终于找到了解决办法。波纹管代码对我来说工作正常。

    1. 包括 Google Recaptcha api js

      <script src="https://www.google.com/recaptcha/api.js"></script>
      
    2. 添加元素 Html

       <div class="g-recaptcha" id="recaptcha" ></div>
      
    3. 添加脚本

      <script type="text/javascript">
        $(document).ready(function() {
          $("[element_id_or_class]").fancybox({
             padding     : 0,
             maxWidth : 800,
             maxHeight    : 600,
             fitToView    : false,
             width        : 'auto',
             height       : 'auto',
             autoSize : true,
             openEffect   : 'none',
             closeEffect  : 'none',           
             ajax: {
               complete: function(jqXHR, textStatus) {
                  grecaptcha.render('recaptcha', {
                      sitekey: [RECAPTCHA_SITE_KEY],
                      callback: function(response) {
                          console.log(response);
                      }           
                  });
              }
            }
          });
       });
       </script>
      

    【讨论】:

    • 或者你可以使用afterLoad回调来渲染recaptcha。
    猜你喜欢
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多