Ajax获取xml信息_Ajax编程_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

Ajax获取xml信息

作者:黑客防线网安Ajax教程基地 来源:黑客防线网安Ajax教程基地 浏览次数:0

本篇关键词:信息获取 '
黑客防线网安网讯:下面是Ajax获取xml的信息://定义一个成员变量var XMLHttpReq;//获取浏览器的信息function createXMLHttpRequest(){        if(window.XMLHttpRequest){ //Mozilla                  XMLHtt...

下面是Ajax获取xml的信息:

//定义一个成员变量
var XMLHttpReq;
//获取浏览器的信息
function createXMLHttpRequest(){
       if(window.XMLHttpRequest){ //Mozilla
                 XMLHttpReq=new XMLHttpRequest();
       }else if(window.ActiveXObject){
                 try{
                           XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
                 }catch(e){
                           try{
                                    XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
                          }catch(e){}
                 }
        }
}
//获取状态信息
function proce(textNameInfor,indexNum){
           if(XMLHttpReq.readyState==4){
                      if(XMLHttpReq.status==200){
                                 var res=XMLHttpReq.responseXML.getElementsByTagName("user-factory") [0].firstChild.data;
                                ///alert(XMLHttpReq.responseXML.xml);
                               res=res.replace(/(^s*)|(s*$)/g,"");
                              if(res == null||res == "null"||res == ""){
                                          document.getElementById(textNameInfor).value='无此条码!';
                                          document.getElementById(textNameInfor).style.color="red";
                                          document.getElementById(indexNum).value=null;
                              }else{ 
                                          document.getElementById(textNameInfor).value='正确!';
                                          document.getElementById(textNameInfor).style.color="black";
                                          document.getElementById(indexNum).value=res;    
                              }
                      }else{
                                          v.value='....';
                      }
           }
} function send(textName,textNameInfor,urlName,indexNum){ 
           var name=document.getElementById(textName).value;
           if(name==""){
                     //textNameInfor.value='必填填不得为空!';
                     document.getElementById(textNameInfor).value='必填填不得为空!';
                     document.getElementById(textNameInfor).style.color="red";
                     return false;
           }else{
                     url=urlName+name;
                     createXMLHttpRequest();
                     XMLHttpReq.open("GET",url,true);
                     v=textNameInfor;
                     XMLHttpReq.onreadystatechange=function(){proce(textNameInfor,indexNum)};
                     XMLHttpReq.send(null);
           }
   }

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-15609-1.html
网站维护教程更新时间:2012-04-05 00:04:25  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer