Jquery加载https url [英] Jquery load https url
问题描述
我有这个问题。在外部网站,我有一个这样的脚本:
I have this problem. In external web site I have a script like this:
<div id="idtest"></div>
<script src="//example.com/widget.js" type="text/javascript"></script>
example.com采用https(允许http和https)。在脚本widget.js的服务器中,我有:
example.com is in https (allow both http and https). In the server in the script widget.js I have:
$('#idtest').load("https://example.com/index.html")
我收到此错误:混合内容:页面位于'thepage'是通过HTTPS加载的,但是请求了一个不安全的XMLHttpRequest端点' http://example.com/index.html '。此请求已被阻止;内容必须通过HTTPS提供。
I get this error: Mixed Content: The page at 'thepage' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://example.com/index.html'. This request has been blocked; the content must be served over HTTPS.
我不明白:为什么错误以及端点为什么是http?
谢谢
I don't understand: why the error and why the endpoint is in "http"? thanks
编辑
更多信息:
如果在widget.js中我这样做:
if in the widget.js I do this:
$('#idtest').load("./index.html")
内容加载,如果我在我的脚本中加载脚本,一切正常现场。
the content is load and all works perfectly if I load the script in my site.
如果我这样做:
x = "https://example.com"
$('#idtest').load(x + "/index.html")
或
$('#idtest').load("https://example.com/index.html")
我收到错误(如果我把脚本放在我的网站或在外部网站)。为什么?
I get the error (if I put the script in my site or in external site). Why?
编辑2
更多信息:
我的网站在django
my site is in django
编辑3
在firefox中我加载了https和http页面。它在Chrome中不起作用。我在firefox网络分析器中看到这种情况时调用网址:
In firefox I load the page in https and http. It doesn't work in Chrome. I see this situation in firefox net analyzer when call the url :
302 https:/ /example.com/index.html
200 http://example.com/index.html [混合内容]
302 https://example.com/index.html 200 http://example.com/index.html [mixed content]
了解这种情况(https to http)?可能是Django重定向问题吗?
What understand this situation (https to http)? Could be a Django redirect problem?
推荐答案
A mixed content error happens when:
- 您尝试加载安全内容<服务不安全的页面上强> SSL (
https
)(http
)
- you try to load secure content SSL(
https
) on a page served insecurely (http
) served
或相反
- 您尝试加载不安全的内容(
http
)安全地提供服务 SSL (https
)服务
- you try to load insecure content (
http
) on a page served securely SSL(https
) served
您的错误消息警告您的呼叫页面已在不安全模式下加载
您尚未明确说明这一点,但您的错误表明您的网页在没有 SSL 的情况下投放。当您尝试加载受保护资源时,这将成为受保护资源和不安全的混合模式问题。
You haven't explicitly explained this, but your error indicated your page is being served without SSL. When you try to load a protected resource this becomes a mixed mode problem of protected resources and insecure.
如果可能,您尝试以相同方式提供参考文件
-
您可以通过 SSL (
https
)
为您的主页提供服务您可以申请 http
You can request the partial page in http
$('#idtest')中的部分页面.load( http://example.com/index.html )
$('#idtest').load("http://example.com/index.html")
或
- 正如您已经解决它一样,请求不带协议的部分页面。现在您的加载文件将使用您页面使用的协议加载。
关于您的特定资源:
我尝试加载:
和
https://example.com/index.html
结果是一样的。我得到了一个包含以下消息的简单页面:
The result was the same. I got a simple page with the message:
该域被建立用于文档中的说明性示例。您可以在未事先协调或要求许可的情况下在示例中使用此域。
This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.
这篇关于Jquery加载https url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!