console
<script>
const xhr = new XMLHttpRequest()
xhr.open('GET', '/a', true)
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 ) {
if(xhr.status === 200) {
} else {
}
}
}
xhr.send(null)
function ajax(url) {
const p = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest()
xhr.open('GET', '/a', true)
xhr.onreadystatechange = function() {
if(xhr.readyState === 4) {
if (xhr.status === 200) {
resolve(123)
} else {
reject('33333333')
}
}
}
xhr.send(null)
})
return p
}
ajax('/1234').catch((e) => {console.log(e)})
</script>