node2:/django/mysite/news/templates#cat displaytestxhr.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Listing 10.3</title>
<link rel="stylesheet" href="../css/main.css"/>
</head>
<body>
<body>
<div id="aa">aaaaa</div>
<div id="elem"></div>
<div id="bb">bbbb</div>
<script>
var xhr;
if (window.ActiveXObject) {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
} else if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
throw new Error('Ajax is not supported by this browser');
}
xhr.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status >= 200 && this.status < 300) {
document.getElementById('elem').innerHTML = this.responseText;
}
}
};
xhr.open('GET','/testxhr/?a=11&b=22&c=53');
xhr.send();
</script>
</body>
</html>
![](https://img-blog.csdnimg.cn/20190219093612978.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3poYW95YW5namlhbjcyNA==,size_16,color_FFFFFF,t_70)