XMLHttpRequest是什么如何完整地运行一次GET请求如何检測错误。

Posted mthoutai

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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‘);
                                }
                            }
                         }
                    }
                 }

以上是关于XMLHttpRequest是什么如何完整地运行一次GET请求如何检測错误。的主要内容,如果未能解决你的问题,请参考以下文章