AJAX creates XMLHttpRequest object
AJAX creates an XMLHttpRequest object:
All current mainstream browsers support the XMLHttpRequest object.
This object can be used to exchange data with the server in the background, thus making it possible to update web page content asynchronously without refreshing the entire page.
Special note: IE5 and IE6 use ActiveXObject.
Create an XMLHttpRequest object compatible with IE5 and IE6:
(1). Create an XMLHttpRequest object as follows:
var xmlhttp=new XMLHttpRequest();
(2). Compatible with IE5 and IE6 (using ActiveX objects):
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");The compatibility code is as follows:
var xmlhttp;
//IE7和IE7以上或者其他标准浏览器
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
//IE5和IE6浏览器
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
new file
<html><!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
//可以自己创建txt文件进行修改
xmlhttp.open("GET","/asset/demo.ajax.php?dm=txt&act=getfruits",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>使用 AJAX 修改该文本内容</h2></div>
<button type="button" onclick="loadXMLDoc()">修改内容</button>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















