【问题标题】:wordpress contact form 7 plugin returns js error on consolewordpress 联系表格 7 插件在控制台上返回 js 错误
【发布时间】:2015-11-24 09:25:28
【问题描述】:

wordpress 联系表格 7 插件在控制台上返回 js 错误。 这是联系表格。错误出现在自动生成的代码上 插件本身

 <div class="row">

<div class="col-xs-12  col-sm-4">

[text* your-name class:wpcf7-form-control wpcf7-text placeholder "Your Name"] 

[email* your-email class:wpcf7-form-control wpcf7-text wpcf7-email placeholder "E-mail address" ] 

[text your-subject class:wpcf7-form-control wpcf7-text placeholder "Subject"]

</div>

<div class="col-xs-12  col-sm-8">

[textarea your-message class:wpcf7-form-control wpcf7-textarea class:txt placeholder "Message"] 

[submit class:wpcf7-form-control wpcf7-submit class:btn class:btn-primary "SEND MESSAGE" ]

  </div>

 </div>

【问题讨论】:

标签: javascript jquery wordpress


【解决方案1】:

查看您的错误,它清楚地表明您没有将工具提示 js 文件包含到您的页面中,如果不包含它,您将无法调用该函数。

在您的 html 中包含 tooltip.js,然后错误就会消失

对于ajaxForm的错误我找到了以下解决方案。

get the following file from the url

将以下代码添加到您的 function.php 文件中

function theme_name_scripts() {
   wp_enqueue_script( 'ajaxform', get_template_directory_uri() . '/js/ajaxform.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

由于您收到联系表格 7 的错误,因此用户也发布了解决方案。转到JabariHolder提供的解决方案

wordpress solution for contactform 7 error

以下是将脚本加入您的网站。编辑它以获取 tooltip.js 并将其添加到 function.php 文件中

wp_register_script('html5blankscripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.0'); // Custom scripts
wp_enqueue_script('html5blankscripts'); // Enqueue it!

【讨论】:

  • 修复了contact form7错误但TypeError中仍有错误:$(...).tooltip is not a function localhost/wp_emerge/wp-content/themes/emerge/js/main.js Line 15
  • 您是否将 tooltip.js 脚本加入到您的函数 php 中?
  • 没有这样的文件 tooltip.js 。如果我停用 cotact form 7 插件,整个网站都可以正常工作
  • 我猜您的联系表单插件或您的网站中缺少插件。最好的办法是对插件进行入队,看看它是否有效。
  • 帮我修复这个头文件 $headers = "From: ".trim($_POST[your_name])." \r\n回复-To:".trim($_POST[your_email]) ;
【解决方案2】:

解决了所有的麻烦..只需将这个放在header参数之后..

$email = mail(get_option("admin_email"),trim($_POST[your_subject]),stripslashes(trim($_POST[your_message])),$headers, "-fsender@domain.com");

【讨论】:

    【解决方案3】:

    如果任何人收到 user5549553 提到的错误

    Uncaught TypeError: this.ajaxForm is not a function
        at a.fn.init.$.fn.wpcf7InitForm (scripts.js?ver=5.1.3:14)
        at HTMLDocument.<anonymous> (scripts.js?ver=5.1.3:10)
        at i (jquery.js?ver=1.12.4:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
        at Function.ready (jquery.js?ver=1.12.4:2)
        at HTMLDocument.K (jquery.js?ver=1.12.4:2)
    

    并且您已将contact-form-7 更新到ver5.1.3。这可能是因为从 CDN 提供了 wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.1.3 文件。

    就我而言,我使用的是 W3 Total Cache 插件。一旦我使用 Rejected files: 设置从 CDN 中删除了这个文件,错误就消失了。

    【讨论】:

      猜你喜欢
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-13
      • 1970-01-01
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多