阿贾克斯GET请求通过HTTPS [英] Ajax GET request over HTTPS

查看:190
本文介绍了阿贾克斯GET请求通过HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何发送一个Ajax 获取请求了 HTTPS

How can I send an ajax GET request over HTTPS?

$获得抛出这样的:

XMLHttpRequest cannot load https://********. Origin null is not allowed by Access-Control-Allow-Origin. 

有另一种方法或一些变通方法来得到这个工作?

Is there another way or some workaround to get this working?

如果我浏览到的网址是 Chrome浏览器我能够得到响应。我不明白为什么它不应该在一个Ajax请求工作的工作。

If I navigate to the url with Chrome I'm able to get the response. I see no reason why it shouldn't work work over an ajax request.

推荐答案

您不能使一个AJAX请求到 HTTPS 页面,如果你目前在 HTTP 的<一个href="https://developer.mozilla.org/en-US/docs/JavaScript/Same_origin_policy_for_JavaScript">Same原产地政策

You cannot make an AJAX request to an https page if you are currently in http because of the Same Origin Policy.

主机 端口计划(协议)必须按顺序为AJAX请求的工作是一样的。

The host, port and scheme (protocol) must be the same in order for the AJAX request to work.

您既可以确保原始页面相同的主机和方案或实施 CORS (跨域资源共享)在目标域允许这个特定的请求。

You can either make sure that the originating page is on the same host and scheme or implement CORS (cross-origin resource sharing) on the target domain to permit this particular request.

这篇关于阿贾克斯GET请求通过HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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