ajax 跨域丢失cookie的问题
2015-10-08 16:51
507 查看
原生ajax请求方式:
var xhr = new XMLHttpRequest(); xhr.open("POST", "http://xxxx.com/demo/b/index.php", true); xhr.withCredentials = true; //支持跨域发送cookies xhr.send();
jquery的ajax的post方法请求:
$.ajax({
type: "POST",url: "http://xxx.com/api/test",dataType: 'jsonp',xhrFields: {withCredentials: true},crossDomain: true,
success:function(){
},
error:function(){
}
})
服务器端设置:
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: http://www.xxx.com");
相关文章推荐
- 仿微信选择图片之——加载内存中所有图片
- js-对象prototype属性剖析
- navigationBar导航条和navigationItem设置:基本搞定导航条上的文字和按钮以及各种跳转,
- 触发器
- C#下的摄像机标定
- 【SQL】全关系操作
- 撤销修改
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc区别
- bzoj1001 【beijing2006】狼抓兔子
- 面试题——Struts2如何防止表单重复提交
- 管理修改
- PS1
- Java 集合系列07之 Stack详细介绍(源码解析)和使用示例
- @import Modules机制
- 设置控件圆角,任意角 (网址)
- git多账号配置
- js复制剪切应该很简单
- ant+dbunit 导xml到mysql
- static作用(修饰函数、局部变量、全局变量)转自http://www.cnblogs.com/stoneJin/archive/2011/09/21/2183313.html
- 将几个实体对象变成