jQuery .load()在https://连接上不起作用

最近,我在我的网站上添加了一个使用Cloudflare的SSL证书,此后,下面的函数开始返回0 (error),并且从不加载URL的内容,我该怎么做才能解决该问题。 / p>

$(function () {
  EnderReact();
});

function EnderReact () {
  $("a").on("click",function () {
    event.preventDefault();

    if (!(($(this).attr('href')).replace(/\s/g,'') > 0)) {
      var TheURL = $(this).attr('href');
    }

    if (TheURL && !(TheURL.indexOf("http") > -1 || TheURL.indexOf("https") > -1 || TheURL.indexOf("//") > -1)) {
      TheURL = "https://" + TheURL + "?v=0.001";
      $("#MyDiv").load(TheURL,{ name: '' },function (response,status,xhr) {
          EnderReact();
          if (status == "error")
            alert(xhr.status + " (" + xhr.statusText + ")");
          else
            alert(xhr.status + " (" + xhr.statusText + ")");
        });
    }
  });
}

注意:控制台错误为ERR_NAME_NOT_RESOLVED

duke3032 回答:jQuery .load()在https://连接上不起作用

这是cloudflare ssl设置的普遍问题。  检查他们的gaq:

here

尝试此代码,看看哪一行有错误:

data
,

您在click函数上使用了事件默认功能,但没有在函数中传递事件参数

对此进行更改,并在每一行下方发出警报!

$(“ a”)。on(“ click”,函数(事件)

,

使用此代码:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
本文链接:https://www.f2er.com/3128742.html

大家都在问