Create an XMLHttpRequest object. Read the method for creating an XMLHttpRequest object. Method 1: We recommend that you create a Boolean variable varxmlhttp = false; // check whether IE browser is used. try {// if the JS version is later than 5 xmlhttp = newActiveXObject ("> <LINKhref
Method 1: recommended
// Create a Boolean variable
Var xmlhttp = false;
// Check whether IE browser is used
Try {
// If the JS version is later than 5
Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP ");
Alert ("You are using Microsoft Internet Explorer .");
} Catch (e ){
// If not, ActiveX objects of earlier versions are used.
Try {
// If you are using IE
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
Alert ("You are using Microsoft Internet Explorer .");
} Catch (e ){
// Use a non-IE browser
Xmlhttp = false;
}
}
// If you are using an IE non-browser
If (! Xmlhttp & typeof XMLHttpRequest! = 'Undefined '){
Xmlhttp = new XMLHttpRequest ();
Alert ("You are not using Microsoft Internet Explorer .");
}
Method 2:
Var xmlhttp;
// If ActiveX objects are available, you must use IE browser.
(! Window. ActiveXObject ){
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
} Else {
// Use Javascript for processing
Xmlhttp = new XMLHttpRequest ();
}