在IE6中创建XMLHTTPRequest

I am applying the following Javascript in a check form function:-

var msg1="";
function check_si_form_info(form,mark,edit){

     if(mark==10 || mark=="all"){
     if(form.email.value==""){
       si_check_email.innerHTML="";
       si_check_email.style.height="0px";
       form.email.style.backgroundColor="#FFFFFF";
     }else{ 
       var i=form.email.value.indexOf("@");
       var j=form.email.value.indexOf(".");
       if((i<0)||(j<0)){
         si_check_email.innerHTML="The email address format is incorrect!";
         si_check_email.style.height="auto";
         form.email.style.backgroundColor="#FFD5FF";
         return false;                              
       }
     else{
        var email = form.email.value;
            xmlhttp=new XMLHttpRequest(); //HERE!!!!
            xmlhttp.open('get','si/check_si_email.php?email='+email,true);
            xmlhttp.onreadystatechange = function(){
                if(xmlhttp.readyState == 4){
                    if(xmlhttp.status == 200){
                        msg1 = xmlhttp.responseText;
                        if(msg1 == '1'){
                        si_check_email.innerHTML="email address has been used!";
                        si_check_email.style.height="auto";
                        form.email.style.backgroundColor="#FFD5FF";
                        }else if(msg1 == '2'){
                        si_check_email.innerHTML="";
                        si_check_email.style.height="0px";
                        form.email.style.backgroundColor="#FFFFFF";
                        }else if(msg1 == '3'){
                        si_check_email.innerHTML="";
                        si_check_email.style.height="0px";
                        form.email.style.backgroundColor="#FFFFFF";
                        }
                    }//200
                }//4            
            }//onreadystatechange
            xmlhttp.send(null);
            }
            if (msg1 == '1'){
            return false;
            }
     }
    }

   }

In IE 7 or above, the scripts work perfectly well. But in IE6, the browser always mention the "XMLHttpRequest()" is not defined. If I wish to define it, where and what shall I input?? Thanks a lot!

In IE6 you need to use new ActiveXObject('Microsoft.XMLHTTP') to create the XHR object.

var xmlhttp;
try {
    xmlhttp = new XMLHttpRequest(); // real browsers
} catch(e) {
    xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); // <=IE6
}

But you should really use jQuery, it does all the dirty work for you.
Additionally dropping IE6 support wouldn't be a bad thing.

xmlhttp=new XMLHttpRequest();
if(!xmlhttp && typeof ActiveXObject != "undefined"){
   try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
   if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){xmlhttp=false;}
  }

In the article on AJAX on Wikipedia you have an example how to enable support of AJAX within IE 5, IE 5.5 and IE 6. The example is as follows:

/*
   Provide the XMLHttpRequest constructor for Internet Explorer 5.x-6.x:
   Other browsers (including Internet Explorer 7.x-9.x) do not redefine
   XMLHttpRequest if it already exists.

   This example is based on findings at:
   http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx
*/
if (typeof XMLHttpRequest == "undefined")
  XMLHttpRequest = function () {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
      catch (e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
      catch (e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e) {}
    //Microsoft.XMLHTTP points to Msxml2.XMLHTTP and is redundant
    throw new Error("This browser does not support XMLHttpRequest.");
  };