在单页面应用中,有时候需要在服务器中获取cookies, token等等,,但是ajax并不获取cookies 和token
这是因为ajax的设计就不是这样用的
不过我们模拟发送http请求
var xhr = ((window.XMLHttpRequest &&(window.location.protocol !== “file:” || !window.ActiveXObject)) ?window.XMLHttpRequest();} :{return new window.ActiveXObject(“Microsoft.XMLHTTP”);} catch (e) {}});{var request = xhr();request.open(“GET”,(‘…(your url)…’));request.send();}getCookies();
有一种缘,放手后成为风景,有一颗心,坚持中方现真诚。