This article mainly describes how to create Ajax objects and compatible with multiple browsers, you need friends can refer to the
<script>
function Createajax () {
var request=false;
There is a XMLHttpRequest in the Window object that is not IE, including (IE7 version)
if (window. XMLHttpRequest) {
request=new XMLHttpRequest ();
if (request.overridemimetype) {
request.overridemimetype ("Text/xml");
}
There is an ActiveXObject property in the Window object that is IE
}else if (window). ActiveXObject) {
var versions=[' microsoft.xmlhttp ', ' MSXML. XMLHTTP ', ' msxml2.xmlhttp.7.0 ', ' msxml2.xmlhttp.6.0 ', ' msxml2.xmlhttp.5.0 ', ' msxml2.xmlhttp.4.0 ', ' MSXML2. xmlhttp.3.0 ', ' MSXML2. XMLHTTP '];
for (var i=0 i<versions.length; i++) {
try{
request=new ActiveXObject (Versions[i]);
if (request) {return
request
}
} catch (e) {
request=false
}}} return request;
}
var ajax=createajax ();
Alert (AJAX);
</script>