jQuery ajax 和 SSL? [英] jQuery ajax and SSL?

查看:48
本文介绍了jQuery ajax 和 SSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的网站中,某些页面使用 SSL,但大多数页面不使用(因为它们需要被网络机器人抓取).

In our site certain pages use SSL, most pages however don't (as they need to be crawled by web bots).

它几乎可以归结为用户登录的任何页面,只有少数例外是在 SSL 下,

It pretty much boils down to any page where the user is logged in, with a few exceptions is under SSL,

但用户首先必须从非 https 页面登录(登录表单是一种从任何页面的屏幕顶部掉落的表单).

But the user first has to login from a non https page (The login form is a form that drops from the top of the screen on any page).

所以,

如何强制 ajax 上的请求使用 SSL?

How can I force the requests over ajax to use SSL?

这还安全吗?

推荐答案

它违反了 JavaScript 的同源策略,因为它没有将 HTTPS URL 视为与 HTTP URL 来自同一来源.您可以通过使用 JSONP 或在来自 Web 服务的响应中设置 Access-Control-Allow-Origin 标头来解决此问题.许多网络服务已经设置为执行此操作.

It violates JavaScript's same-origin policy, because it doesn't see the HTTPS URL as being from the same source as the HTTP URL. You can get around this by using JSONP or setting a Access-Control-Allow-Origin header in the response from the web service. Many web services will be setup to do this already.

这篇关于jQuery ajax 和 SSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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