script>
function createXMLHttp()
{
var ret = null;
try {
ret = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e) {
try {
ret = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (ee) {
ret = null;
}
}
if (!ret typeof XMLHttpRequest != 'undefined')
ret = new XMLHttpRequest();
return ret;
}
function loadXmlToElement(fragment_url, element_id)
{
var element = document.getElementById(element_id);
element.innerHTML ='img src="loading.gif" border="0"/>数据加载中...br/>';
var xmlhttp = createXMLHttp();
xmlhttp.open("GET", fragment_url);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 xmlhttp.status == 200)
{
//alert(xmlhttp.responseXML.getElementsByTagName("data")[0].childNodes[0].nodeValue);
element.innerHTML =
unescape(xmlhttp.responseXML.getElementsByTagName("data")[0].childNodes[0].nodeValue);
if(!element.innerHTML || element.innerHTML == "/n")
{
try{
element.innerHTML = unescape(xmlhttp.responseXML.firstChild.childNodes[1].nodeValue);
}catch(e){}
}
}
}
xmlhttp.send(null);
}
/script>
div id="data">
/div>
script>
var url="t.xml";
//alert(url);
loadXmlToElement(url,"data");
/script>