- 正常的请求,405 Method Not Allowed 首先确认是否真的不允许所用方法,然后看一下content-type 是不是正常;
- ajax 302 当服务器将302响应发给浏览器时,浏览器并不是直接进行ajax回调处理,而是先执行302重定向——从Response Headers中读取Location信息,然后向Location中的Url发出请求,在收到这个请求的响应后才会进行ajax回调处理。响应貌似必须是200才会处理,如果还是302,会再次跳转;
- 浏览器在遇到301,302,303时,会把post方法替换成get,忽略post的数据体,自动重发一次请求; 307浏览器不会将post改为get.
- position:fixed和absolute类似,如果不写方向,默认是当前位置;
- 站外图片,使用a或者location不能下载,会打开新的页面,此时可以使用异步下载;
const fileName = url.split('/').pop(); let xhr = new XMLHttpRequest(); xhr.open('get', url, true); xhr.responseType = 'blob'; xhr.onload = function () { if (xhr.status === 200) { const data = xhr.response; const url = window.URL.createObjectURL(data) let a = document.createElement('a'); a.download = fileName; a.href = url document.body.appendChild(a); a.click(); document.body.removeChild(a); window.URL.revokeObjectURL(url); } } xhr.send()