简体   繁体   English

Codeigniter - jquery.min.js:4 混合内容:内容必须通过 HTTPS 提供

[英]Codeigniter - jquery.min.js:4 Mixed Content: the content must be served over HTTPS

I have a JS script that post data via AJAX.我有一个通过 AJAX 发布数据的 JS 脚本。 When I put the script on my server, the posting URL is https but when I view the js via view page source online, the URL starts with http.当我将脚本放在我的服务器上时,发布 URL 是 https,但是当我通过在线查看页面源查看 js 时,URL 以 http 开头。

I am receiving the below error.我收到以下错误。

jquery.min.js:4 Mixed Content: The page at ' https://www.mywebsite.com/ ' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ' http://www.mywebsite.com/bookmark '. jquery.min.js:4 混合内容:“ https://www.mywebsite.com/ ”页面已通过 HTTPS 加载,但请求了不安全的 XMLHttpRequest 端点“ http://www.mywebsite.com/bookmark ”。 This request has been blocked;此请求已被阻止; the content must be served over HTTPS.内容必须通过 HTTPS 提供。

Script on server服务器上的脚本

 $(document).on("click","#bookmark",function(a){a.preventDefault();var t=$(this).attr("bookmark_id"),e=$("input[name=msmm_tn").val(),s=$(this);$.ajax({type:"POST",url:"https://www.mywebsite.com/bookmark",data:{msmm_tn:e,bookmarkid:t},dataType:"json",success:function(a){"X"==a.status&&(s.find("i").addClass("green"),s.removeAttr("href"))}})})

When I click the js file in my web browser, the https:// is http.当我在 Web 浏览器中单击 js 文件时,https:// 是 http。 I cannot figure out why.我不明白为什么。

This error is shown when either website is loaded on "HTTPS:"在“HTTPS”上加载任一网站时会显示此错误:
and your libraries are loaded on "HTTP:"并且您的库加载在“HTTP:”上
OR
This error is shown when either website is loaded on "HTTP:"在“HTTP:”上加载任一网站时会显示此错误:
and your libraries are loaded on "HTTPS:"并且您的库加载在“HTTPS:”上

In Codeigniter resolve this by editing "config.php".在 Codeigniter 中,通过编辑“config.php”来解决这个问题。
Open "application/config/config.php" in your project and change the value of在您的项目中打开“application/config/config.php”并更改值

$config['base_url']

Add "s" in the value在值中添加“s”
from来自

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];

to

$config['base_url'] = 'https://'.$_SERVER['HTTP_HOST'];

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

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