尝试从HTTPS网站从HTTP服务器检索JSONP [英] Trying to retrieve JSONP from HTTP server from a HTTPS website

查看:130
本文介绍了尝试从HTTPS网站从HTTP服务器检索JSONP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于HTTPS的网站,我有一个JS代码,可以从基于HTTP的网站获取数据。我收到HTTP服务器不受信任的错误。
虽然相同的代码适用于HTTP到HTTP。但不是HTTP到HTTPS。
这是错误:

I have a website based on HTTPS, and I have a JS code the get data from a website based on HTTP. I get an error that the HTTP server is not trusted. While the same code works on HTTP to HTTP. But not on HTTP to HTTPS. This is the error:


混合内容:' https://www.33k.com/player/playerudan.php '是通过HTTPS加载的,但请求了一个不安全的脚本' http://33k.thepuremix.net/json.xsl 。此请求已被阻止;内容必须通过HTTPS提供。

Mixed Content: The page at 'https://www.33k.com/player/playerudan.php' was loaded over HTTPS, but requested an insecure script 'http://33k.thepuremix.net/json.xsl'. This request has been blocked; the content must be served over HTTPS.

为了获取此数据,我使用类似下面的代码:

For getting this data I use something like the following code:

var URL = "http://33k.thepuremix.net/json.xsl"
$.getJSON( URL, function( data) {
 console.log( data );
});

任何想法如何解决或使其工作。在Icecast上是否有这样的Crossdomain.xml,我可以给它配置或其他什么来解决它?

Any idea how to fix it or make it working. Is there such a Crossdomain.xml on Icecast that I can give configure or anything else to fix it?

更新
以上链接是两个不同的网站。这不是一个子域问题。这些链接看起来很像。域A(HTTPS)希望从域B(HTTP)获取JSON。

UPDATE: The above links are two different websites. It is not a sub-domain matter. The links just look alike a bit. Domain A(HTTPS) wants to get JSON from domain B (HTTP).

推荐答案

从HTTPS调用HTTP被设计阻止@RoryMcCrossan在评论(同源策略)中提到,您可以将脚本从HTTP移动到HTTPS或制作后端脚本(例如在PHP中)并从中调用HTTP,如:

Calling HTTP from HTTPS is blocked by design as @RoryMcCrossan mentioned in the comments (Same Origin Policy), you can either move your script from HTTP to HTTPS or make a backend script (in PHP for example) and call HTTP from it like:

JavaScript(HTTPS) -> PHP(HTTPS) -> PHP(HTTP)
JavaScript(HTTPS) <- PHP(HTTPS) <- PHP(HTTP)

在PHP中创建http请求的参考: PHP中的Http请求

Reference to creating a http request in PHP: Http Request in PHP

这里还有一些关于同源政策

这篇关于尝试从HTTPS网站从HTTP服务器检索JSONP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆