Chinaunix首页 | 论坛 | 博客
  • 博客访问: 368467
  • 博文数量: 162
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1501
  • 用 户 组: 普通用户
  • 注册时间: 2016-10-21 19:45
文章分类
文章存档

2018年(1)

2017年(101)

2016年(60)

分类: Python/Ruby

2017-01-02 16:06:22


python代码:

response = HttpResponse(json.dumps(ret), content_type="application/json")
response.__setitem__('Access-Control-Allow-origin', '*')
response.__setitem__('Access-Control-Allow-Headers', 'x-requested-with,content-type')
其他(php):
在被请求的Response header中加入



[php] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. // 指定允许其他域名访问  
  2. header('Access-Control-Allow-Origin:*');  
  3. // 响应类型  
  4. header('Access-Control-Allow-Methods:POST');  
  5. // 响应头设置  
  6. header('Access-Control-Allow-Headers:x-requested-with,content-type');  
阅读(1264) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~