复制代码 代码如下:
<SCRIPT LANGUAGE="JavaScript">
<!--
function createRequestObject() {
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); //for IE explorer
usewin = "msxml";
}
catch(e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //for IE
usewin = "microsoft";
}
catch(e) {
try{
xmlhttp=new XMLHttpRequest();}catch(e){} //for Mozilla
}
}
if(!xmlhttp&&typeof XMLHttpRequest!="undefined") { //object is null
xmlhttp=new XMLHttpRequest();
usewin = "undefined";
}
return xmlhttp;
}
function sendRequest() {
try{
var url="/xxxxx.xxx?para_1="xxx"¶_2="xxxx";
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader('Content-Type', "text/xml"); //set request type (xml)
xmlhttp.onreadystatechange = handleResponse; //if state changed, function handleResponse called
xmlhttp.send(null); //send request
}
catch(e){
alert('Request send failed.');
}
finally{}
}
function handleResponse() //state changed
{
try {
if((xmlhttp.readyState == 4)&&(xmlhttp.status == 200)){ //Received success
var response = xmlhttp.responseXML.documentElement; //get response obj
var node_ = response.getElementsByTagName('user'); //example
var s="";
var grouplist=document.getElementById("guserlist");//example
var objX=null;
for(var i=0;i<node_.length;i++) {
var s1=node_[i].childNodes[0].childNodes[0].nodeValue; //id --example
var s2=node_[i].childNodes[1].childNodes[0].nodeValue; //name --example
objX=new Option(s2,s2);
grouplist.options[document.scugroupsmodform.guserlist.length]=objX;
}
}
}catch(e){
alert('Response failed.');
}
finally{}
}
//-->
</SCRIPT>
由于环境限制,只能用英文写注释 .... 原谅下...
JS,解析,XML
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com