https页面post数据到http页面


在一个https的页面用如下方式发送请求:
$.post(url,data);
其中url是类似这样的:http://127.0.0.1/index.php
但是chrome浏览器执行到这句时报错:
Mixed Content: The page at 'https://localhost:8443/xxxxxxxxxxx' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:8099/simu.php'. This request has been blocked; the content must be served over HTTPS.
目前想到两种方式:
1.能否通过某种方法绕过https页面不能请求http页面这个限制?
2.在后台发送Post请求。这样就能避开浏览器的限制,希望有个例子参照。
望各位前辈、同仁不吝赐教,十分感谢!



相关链接

post jquery https Ajax 数据 http localhost 页面

顶点的毒酒 9 years, 5 months ago

如果按照你的第一条设想:
建议你尝试一下在https页面里面嵌套一个src为http的iframe。并在iframe里面做post数据操作。 你要解决的问题是先把数据从iframe外面传到里面来。这个通信问题可以使用html5的api:“postmassage”。

如果按照你的第二条设想。

那就是很常规的webservice通信。无论是你用java(比如httpclient)还是php(比如curl),在百度上你会找到很多用例。

灰色的幽默 answered 9 years, 5 months ago

Your Answer