我想做的只有一个是POST。
在IE10 +中,我可以像
一样 const xhr = new XMLHttpRequest()
xhr.onreadystatechange = function (event) {
if (xhr.readyState === 4) {
const statusCode = xhr.status
const responseText = xhr.responseText
if (responseValidator(statusCode, responseText)) {
if (successCallback) successCallback(xhr)
} else {
/** error : blah blah */
}
}
}
xhr.open('POST', url, true)
xhr.timeout = timeoutMillis
xhr.ontimeout = function (event) {
/** blah blah */
}
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.withCredentials = true
xhr.send(data)
//仅用于发布
但是,在IE8,9中只有XDomainRequest,它不支持CORS和HeadSetting。
有谁解决了这个问题?