<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
//惰性函数,即对function对象进行更改,但第二次才会执行该函数。
function createXML(){
var xmlHttp;
try{
//-------开始更改----
createXML = function(){
return xmlHttp = new XMLHttpRequest();
}
//------------------
}catch(e){
try{
createXML = function(){
return xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
}catch(e){
try{
createXML = function(){
return xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}catch(e){
xmlHttp = null;
alert("您的浏览器不支持AJAX!");
}
}
}
return xmlHttp;
}
</script>
</head>
<body>
</body>
</html>
增加运行速度。