1.No 'Access-Control-Allow-Origin' header is present on the requested

近期在接html5的渠道,遇到了跨域的问题,使用 js 的 ajax post 或者get 方法,仅仅要目标URL略微有点不同,就会有跨域问题,浏览器会由于安全问题自己主动拦截。

这个问题事实上不是client能解决的,最好是目标URL的server代码是你能够控制的。最方便的解决方式是在你訪问的server端页面加代码。比方你如今的地址是 http://a.company.com 要訪问 http://b.company.com 。你应该在 http://b.company.com 中增加同意跨域訪问的代码。

PHP代码例如以下:

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');

2.跳转还是会有问题

比方你又在http://b.company.com 的server代码又跳转到 http://c.other.com , 并且 http://c.other.com 不受你控制,那么你能够使用这种小技巧。返回url给js,让js通过 location.href = "http://c.other.com" 来跳转。

http://www.waitingfy.com/archives/1737

html5 cocos2d js Access-Control-Allow-Origin的更多相关文章

  1. Access control allow origin 简单请求和复杂请求

    原文地址:http://blog.csdn.net/wangjun5159/article/details/49096445 错误信息: XMLHttpRequest cannot load http ...

  2. 解决js ajax跨越请求 Access control allow origin 异常

    // 解决跨越请求的问题 response.setHeader("Access-Control-Allow-Origin", "*");

  3. Server-Side Access Control

    Firefox 3.5 implements the W3C Access Control specification.  As a result, Firefox 3.5 sends specifi ...

  4. cocos2d js jsb XMLHttpRequest 中文乱码

    1.首先讲下怎样使用XMLHttpRequest 下面所说的是在cocos2d-x 2.2.2 或者 2.3 版本号中. 首先要明确cocos2d js事实上分两个版本号,一个是html5的版本号,另 ...

  5. Browser security standards via access control

    A computing system is operable to contain a security module within an operating system. This securit ...

  6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade

    XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...

  7. Windows Azure Virtual Network (10) 使用Azure Access Control List(ACL)设置客户端访问权限

    <Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的China Azure. 我们在创建完Windows Azure Virtual Machi ...

  8. HTML5 respond.js 解决IE6~8的响应式布局问题

    HTML5 respond.js 解决IE6~8的响应式布局问题   响 应式布局,理想状态是,对PC/移动各种终端进行响应.媒体查询的支持程度是IE9+以及其他现代的浏览器,但是IE8在市场当中仍然 ...

  9. SELINUX、Security Access Control Strategy && Method And Technology Research - 安全访问控制策略及其方法技术研究

    catalog . 引言 . 访问控制策略 . 访问控制方法.实现技术 . SELINUX 0. 引言 访问控制是网络安全防范和客户端安全防御的主要策略,它的主要任务是保证资源不被非法使用.保证网络/ ...

随机推荐

  1. 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛部分题解

    A 跳台阶 思路:其实很简单,不过当时直接dp来做了 AC代码: #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include& ...

  2. 【CF1015D】Walking Between Houses(构造,贪心)

    题意:从1开始走,最多走到n,走k步,总长度为n,不能停留在原地,不能走出1-n,问是否有一组方案,若有则输出 n<=1e9,k<=2e5,s<=1e18 思路:无解的情况分为两种: ...

  3. BZOJ 2146 Construct

    Construct [问题描述] 随着改革开放的深入推进…… 小T家要拆迁了…… 当对未来生活充满美好憧憬的小T看到拆迁协议书的时候,小T从一位大好的社会主义青年变成了绝望的钉子户. 由于小T的家位于 ...

  4. Codeforces Gym100814 I.Salem-异或 (ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (2015) Arab Academy for Science and Technology)

    这个题就是二进制,找两个数相应的二进制相对应的位置上数不同的最多的个数.异或写就可以. 一开始还想麻烦了,找出来最大的偶数和最大的奇数,最小的偶数和最小的奇数,但是这样想考虑的不全.因为范围比较小,直 ...

  5. Codeforces 919 D Substring

    题目描述 You are given a graph with nn nodes and mm directed edges. One lowercase letter is assigned to ...

  6. Jenkins内存溢出的处理方法

    参考:http://openwares.net/java/jenkens_deploy_to_tomcat_error_of_outofmemoryerror.html上的说明,有如下解释: -Xms ...

  7. 【Objective-C Runtime动态加载】---动态创建类Class

    a.使用objc_allocateClassPair创建一个类Class    const char * className = "Calculator";    Class kc ...

  8. dedecms调用新闻文章列表

    效果如下: 代码如下: <div class="list"> <ul class="d6 ico4"> {dede:list pages ...

  9. Failed to read artifact descriptor for avalon-framework:avalon-framewor

    在工程中,遇到了这个问题,百度了好久并没有满意的解决方案. 网上有一种办法是: 一.修改.m2/repository/avalon-framework/avalon-framework-api/里所有 ...

  10. 关于 Shiro 的权限匹配器和过滤器

    项目源码:https://github.com/weimingge14/Shiro-project演示地址:http://liweiblog.duapp.com/Shiro-project/login ...