IE8发送ajax请求无效

IE是个非常有个性的浏览器,常规的东西在他这个都不太好使。

最开始发送ajax请求,总是不成功,也没啥报错,反正就是请求被忽略了

然后我就考虑用原生的JS来实现,然后就:哎呀  可以了。。。。。。

xhr = new XMLHttpRequest()
xhr.open('post', "http://127.0.0.1:38088/card=idcard")
xhr.setRequestHeader('Content-Type', 'application/json')
xhr.responseType = 'blob'
xhr.send()
xhr.onreadystatechange = function(){
    if (xhr.readyState === 4 && xhr.status === 200) {
        // 兼容IE,只有IE浏览器的navigator有这个方法,谷歌浏览器没有
        if (navigator.msSaveBlob) {
            return navigator.msSaveBlob(xhr.response, fileName)
        }
    }
}
原文地址:https://www.cnblogs.com/shiyixirui/p/15211867.html