先上code:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState==1){
console.log('request opened ')
console.log(document.domain);
}
if(xmlhttp.readyState==2){
console.log('request header recieved ')
}
if(xmlhttp.readyState==4){
console.log('Request finished and response is ready \nResponse code: '+xmlhttp.status)
}
}
server需要authentication才可以访问。
我发现browser会在 xmlhttp 的readyState变成 Opened的时候就会prompt一个登录框。
这时候request还没有send,browser怎么知道需要username password呢?
我想在http request真正发送之前,肯定有个隐蔽的和server的通信。求解释