jquery ajax post 跨域访问带cookie
来源:互联网 发布:gre软件 编辑:程序博客网 时间:2024/05/19 16:04
js:
//显示用户信息
$.ajax("http://ltest.com:2020/test/",{
//提交数据的类型 POST GET
type:"POST",
async:false,
data:{ 'username': username.value, 'password': userpassw.value },
crossDomain:true,
datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
xhrFields: { withCredentials: true },
//成功返回之后调用的函数
success:function(data,status,xhr){
if(data["state"]==1)
{
alert("ok");
}else{
alert("密码或用户名错误");
}
}
});
服务端要加头:
Access-Control-Allow-Origin 不能为“*“,当withCredentials为真是
resp['Access-Control-Allow-Origin'] = req.META.get("HTTP_ORIGIN")
“true”不要写成“True”了,浏览器不认
resp["Access-Control-Allow-Credentials"] = "true"
- jquery ajax post 跨域访问带cookie
- jquery ajax post跨域访问
- ajax post 跨域访问
- 360浏览器 7.1版本兼容模式,jQuery $.post 和$.ajax 跨域访问失效
- jquery ajax在跨域访问post请求的时候,ie9以下无效(包括ie9)
- ajax post 跨域访问的解决
- JQuery ajax跨域访问
- jquery Ajax跨域访问
- Jquery,ajax 跨域访问
- Jquery ajax 跨域访问
- 解决jquery ajax在跨域访问post请求的时候,ie9以下无效(包括ie9)的问题
- jquery实现ajax跨域访问
- JQUERY的ajax跨域访问解决方案
- jquery ajax 跨域访问- HttpClient 方式
- jquery ajax跨域访问完整例子
- JQuery Ajax跨域访问方式
- jquery ajax的跨域访问
- 利用JQuery ajax跨域访问
- Android之多线程
- 2016.8.17纪中比赛总结
- 设计模式——单例模式(c++)
- 学习qt的图表绘制(三)
- 统计每秒工单产生的小工具
- jquery ajax post 跨域访问带cookie
- iOS---CoreData的创建和添加数据
- html 三列布局(两列固定宽度,一列自适应)
- 程序员必学的linux命令(1)
- python实现FSC
- C语言-堆栈、队列 区别
- TCP知识4
- leetcode-java-257. Binary Tree Paths
- 数据结构实验之排序七:选课名单