日期:2014-05-16  浏览次数:20739 次

Ajax读取ASP动态生成的XML问题 - Web 开发 / Ajax
ASP:
response.Write("<?xml version=""1.0"" encoding=""gb2312""?>")
response.Write("<Gzbbs state1=""0"">")
response.Write("<ErrName>n</ErrName>")
response.Write("<ErrText>(错误:631)帐号格式不正确!!</ErrText>")
response.Write("</Gzbbs>")

JS:
<script language="javascript">
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("Get","WebSys/WebSys.asp",true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
var xmldom=xmlhttp.responseXML;
alert(xmldom.getElementsByTagName("Gzbbs")[0].getAttribute("state"));
}
}
xmlhttp.send(null);

</script>

已上JS为何读不到ASP生成的XML了?

------解决方案--------------------
VBScript code
response.contenttype="text/xml"'======这里
response.Write( " <?xml   version= " "1.0 " "   encoding= " "gb2312 " "?> ") 
response.Write( " <Gzbbs   state1= " "0 " "> ") 
response.Write( " <ErrName> n </ErrName> ") 
response.Write( " <ErrText> (错误:631)帐号格式不正确!! </ErrText> ") 
response.Write( " </Gzbbs> ")