简体   繁体   中英

Gravity Forms not loading under https, jQuery is not defined

I am using the Gravity Forms plugin on my WordPress site. I am serving the page over HTTPS and this is breaking the form.

It looks like the issue is how the site is trying to load jQuery. There are 23 JavaScript errors on the page, which seem to be due to a failed jQuery load "Uncaught ReferenceError: jQuery is not defined" .

If I go to the page where the source is trying to pull the jQuery file, you'll see the error:https://code.jquery.com/jquery-1.7.1.min.js?ver=3.4.2

Screenshot of the error:

在此输入图像描述

And this screenshot is the reference in the page source:

在此输入图像描述

So I have been told I'd want to look into that - that's where the ultimate issue is, but I don't really know what to do next.

Is it failing because of Gravity Forms, the HTTPS plugin from WordPress, or my SSL certificate?

The code.jquery.com domain doesn't support https. You need to load jQuery either from your own domain or from the Google or Microsoft CDNs instead.

To load jQuery from your own domain over https, simply do this:

<?php wp_enqueue_script('jquery'); ?>

To load it from Google's CDN over https, do this:

<?php 
function jquery_cdn() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', false, null);
   wp_enqueue_script('jquery');
}

add_action('wp_enqueue_scripts', 'jquery_cdn');

Omitting the 'https' in the above sample is deliberate; it ensures that jQuery will be loaded over the same protocol as your site, be it HTTP or HTTPS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM