Ajax请求设置xhrFields的withCredentials为true实现跨域访问

xhrFields   Object类型  1.5.1 新增

一个具有多个"字段名称-字段值"对的对象,用于对本地XHR对象进行设置。一对「文件名-文件值」在本机设置XHR对象。例如,如果需要,你可以用它来为跨域请求设置XHR对象的withCredentials属性为true

$.ajax({
   url: a_cross_domain_url,
   // 将XHR对象的withCredentials设为true
   xhrFields: {
      withCredentials: true
   }
});
posted @ 2016-05-06 15:04  fliu  阅读(14349)  评论(0)    收藏  举报