XMLHttpRequest是什么、怎样完整地执行一次GET请求、怎样检测错误。

                     var xmlhttp;
                     function LoadXmlDoc(url){
                     xmlhttp = null;
                     if(window.XMLHttpRequest){ //code for all new browsers
                         xmlhttp=new XMLHttpRequest();
                     }else if(window.ActiveXObject){//IE5 and IE6
                         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                     }
                    if(xmlhttp!=null){
                        xmlhttp.onreadystatechange=function (){
                            if(xmlhttp.readyState==4){ // loaded ...
                                if(xmlhttp.state==200){
                                    //success,...our code here ...
                                }else{
                                    alert('Problem retrieving XMl data');
                                }
                            }
                         }
                    }
                 }

原文地址:https://www.cnblogs.com/huangjihua/p/4125146.html