我正在编写一个使用 AJAX 与服务器通信的 chrome 扩展程序。我想从 AJAX 响应中读取内容KEY,set-cookie但我找不到这样做的方法。
我已经尝试document.cookie过xhr.getAllResponseHeaders()
$.get(myURL,
function (output, status, xhr) {
console.log(document.cookie); //empty
console.log(xhr.getAllResponseHeaders());
//Only Connection and Content-Type shows
}
);
原始响应标头是:
Connection:Close
Content-Type:text/html
Set-Cookie:KEY=DFDSFDCB; PATH=/;
我知道根据规范,getAllResponseHeaders()应该过滤掉set-cookie字段。有什么解决方法吗?