问题描述
我的网站使用HTTP和HTTPS协议;它不影响该内容。我的网站使用jQuery的Ajax调用,填补了页面上的一些地区也。
My site uses http and https protocol; it doesn't affect the content. My site uses jQuery ajax calls, which fills some areas on the page, too.
现在,我想办通过https所有Ajax调用。 (请不要问我为什么:))当我和HTTPS协议的页面,Ajax请求工作。当我与HTTP协议的页面上,我得到一个JavaScript错误:访问受限制的URI被拒绝
Now, I would like to do all ajax calls over https. (please dont ask me why :))When I am on a page with https protocol, ajax requests are working.When I'm on a page with http protocol, I get a javascript error:Access to restricted URI denied
我知道,这是一个跨领域的问题(事实上,这是一个跨协议的问题),我知道我应该使用相同的协议在ajax调用作为当前页面上。
I know that this is a cross domain problem (in fact, it's a cross protocol problem), and I know that I should use the same protocol in ajax calls as on the current page.
不过,我想所有的Ajax调用是HTTPS,并呼吁他们这是通过HTTP的网页上。有任何解决方法来实现这一(一些JSON /代理解决方案),或者是根本不可能的?
Still, I want to all ajax calls to be https, and call them on a page that was served over http.Is there any workaround to achieve this (some json/proxy solution?), or is it simply impossible?
推荐答案
添加访问控制 - 允许 - 产地标头从服务器
Add the Access-Control-Allow-Origin header from the server
Access-Control-Allow-Origin: https://www.mysite.com
http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing
这篇关于使用https的HTTP页面上的Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!