wordpress contact form 7 plugin returns js error o

2019-08-09 19:33发布

问题:

wordpress contact form 7 plugin returns js error on console. this is the contact form . the error is on auto genarated code by the plugin itself

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

回答1:

Looking at your error, it clearly states that you have not included the tooltip js file into your page and without including it, you cannot call the function.

include the tooltip.js in your html and then the error would go away

for the error on the ajaxForm error I found the following solution.

get the following file from the url

add the following code to your function.php file

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' );

since you are getting the error with contact form 7 the user has posted a solution too. go to the solution provided by JabariHolder

wordpress solution for contactform 7 error

The following is to enque a script onto your website. edit it to get tooltip.js and add it to function.php file

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


回答2:

fixed all the trouble.. just put this one after the header parameter..

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


回答3:

If any one is getting error mentioned by 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)

and you have updated to contact-form-7 to ver5.1.3. It may be because of the wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.1.3 file getting served from CDN.

In my case I was using the W3 Total Cache plugin. Once I removed this file from the CDN using the Rejected files: setting the error was gone.