为什么读不出来值?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ajax</title>
</head>
<body>
<input type=text id=obj name=obj value="test"></text>
<button onclick ="ajax('data.xml');">ajax</button>
</body>
</html>
<script>
function ajax(file)
{
var xmlObj=null;
if(window.XMLHttpRequest)
{
xmlObj=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
xmlObj=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
return;
}
xmlObj.onreadystatechange=function(){
alert(xmlObj.readyState);
if(xmlObj.readyState==4)
{
obj.value =xmlObj.responseXML.getElementsByTagName("data")[0].firstChild.data;
//processXML("obj",xmlObj.responseXML.getElementsByTagName('data')[0].firstChild.data);
}
}
xmlObj.open('GET',file,true);
xmlObj.send('');
}
function processXML(obj,data)
{
document.getElementById(obj).innerText =data;
}
</script>
data.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
this is a test
</data>
</root>