<script>
loadDoc();
function loadDoc() {
// 1. 创建xhttp
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
// 2. 设置回调
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText)
}
};
// 3. 发起请求,Ajax 不能跨域,xhr是异步请求
xhttp.open("GET", "<http://localhost:8080/ajax/hello>", true);
xhttp.send();
}
</script>
document.getElementById("username").onblur
- 原生Axio入门
- 导入:
<script src="<https://unpkg.com/axios/dist/axios.min.js>"></script>