我将我的AJAX请求代码切换为...
return fetch("computerssuck?" + qs)
.then(res => res.json())
.then(data => {
...
})
.catch(err => console.log(err));现在它返回302,没有响应。
当我使用浏览器或XMLHttpRequest请求相同的页面时,它会工作并返回200和一些JSON。
为什么Fetch不能工作?
这是原始代码。
xhr.open('get', "computerssuck?" + qs, true);
xhr.onload = function () {
...
}.bind(this);
xhr.send();这两组代码都可以在我的dev机器上本地运行。
Chrome说,“加载响应数据失败。”在检查器和一些JSON解析代码崩溃。
发布于 2018-03-25 06:07:46
默认情况下,fetch不发送身份验证cookie。
解决方案就在这里...Fetch API with Cookie
https://stackoverflow.com/questions/49468858
复制相似问题