Ajax状态

前端之家收集整理的这篇文章主要介绍了Ajax状态前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var xhr = new XMLHttpRequest();
xhr.open("GET","http://localhost:8080",true);
xhr.onreadystatechange = function(){
	
    switch(this.readyState){
    	case 0:
    		console.log('request has not been initialized');
    		break;
    	case 1:
    		console.log('server connection established');
    		break;
	case 2: 
			console.log('request received');
			break;
	case 3: 
			console.log('processing request');
			break;
	case 4:
			console.log('request finished and response is ready');
			console.log(this.responseText)
			break;
    }

}
xhr.send();
原文链接:/ajax/162409.html

猜你在找的Ajax相关文章