ajax请求传递cookie
服务器端要做些返回头的修改:
response.setHeader("Access-Control-Allow-Credentials","true");
前端ajax请求可以设置如下:
$.ajax({ url:_url, type:"get", data:"", dataType:"json", xhrFields: { withCredentials: true }, success: function(){} })
当需要对全局进行配置时可以设置:
$.ajaxPrefilter(function( options, originalOptions, jqXHR ) { options.xhrFields = { withCredentials: true } });