简体   繁体   English

重力形式未在https下加载,jQuery未定义

[英]Gravity Forms not loading under https, jQuery is not defined

I am using the Gravity Forms plugin on my WordPress site. 我在我的WordPress网站上使用Gravity Forms插件。 I am serving the page over HTTPS and this is breaking the form. 我通过HTTPS服务页面,这打破了表单。

It looks like the issue is how the site is trying to load jQuery. 看起来问题是网站如何尝试加载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" . 页面上有23个JavaScript错误,这似乎是由于jQuery加载失败"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 如果我转到源程序试图拉取jQuery文件的页面,您将看到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? 它是由于Gravity Forms,WordPress的HTTPS插件或我的SSL证书而失败吗?

The code.jquery.com domain doesn't support https. code.jquery.com域不支持https。 You need to load jQuery either from your own domain or from the Google or Microsoft CDNs instead. 您需要从您自己的域或从Google或Microsoft CDN加载jQuery。

To load jQuery from your own domain over https, simply do this: 要通过https从您自己的域加载jQuery,只需执行以下操作:

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

To load it from Google's CDN over https, do this: 要通过https从Google的CDN加载,请执行以下操作:

<?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; 省略上述样本中的“https”是故意的; it ensures that jQuery will be loaded over the same protocol as your site, be it HTTP or HTTPS. 它确保jQuery将通过与您的站点相同的协议加载,无论是HTTP还是HTTPS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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