Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1192958
  • 博文数量: 272
  • 博客积分: 3899
  • 博客等级: 中校
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-15 14:53
文章分类

全部博文(272)

文章存档

2012年(272)

分类: 网络与安全

2012-06-25 14:28:55

首先,关于same origin policy,简单描述如下:
 => Success  

=>Success

https://store.company.com/secure.html =>Failure => Different protocol

=> Failure => Different port

=> Failure => Different host

众所周之,在ajax中,post受到same origin policy的限制,是不能跨域的。这个限制是在浏览器内部完成的。

但是对于同一个域下的不同子域,在一些条件下还是可以跨域post的。

测试环境,如下三个域:
############# test
127.0.0.1 tt1.test.com
127.0.0.1 tt2.test.com
127.0.0.1 test.com

然后设定一个html页面: 4.html, 放到 http://tt1.test.com 下,我们将利用它去跨域post
关键代码如下:

  1. 4.html
阅读(885) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~