AJAX執行過程和原理
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>AJAX執行過程和原理</title>
</head>
<body>
<script>
window.onload = function(){
var $http;
if(window.XMLHttpRequest){
$http = new XMLHttpRequest();
}else{
$http = new ActiveXObject("Microsoft.XMLHTTP");
}
$http.open("GET","http://localhost:8081/user/test/22",true);
$http.send();
$http.onreadystatechange = function() {
console.log($http.readyState,$http.status,$http.responseText);
if($http.readyState == 4 && $http.status==200){
console.log($http.responseText);
}
}
}
</script>
</body>
</html>