ajax 请求设置请求时请求头携带cookie

ajax 请求时设置请求头,需要在请求中添加 withCredentialstrue

$.ajax({
	url:请求地址,
	datatype:数据类型,
	type:请求类型, // post、get、delete、put
	data:请求数据,
	xhrFields: {
		withCredentials: true
	},
	success:function(data){
	//请求成功时执行的动作
	},
	error:function(data){
	//请求失败时执行的动作
	}
});

更多推荐

ajax 请求设置请求时请求头携带cookie