|
复制代码 代码如下:
<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>
由于环境限制,只能用英文写注释 .... 原谅下...
JavaScript技术:JS提交并解析后台返回的XML的代码,转载需保留来源!
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。