+ -
当前位置:首页 → 问答吧 → 求助 !xmlhttp.responseXML 总是为空?????

求助 !xmlhttp.responseXML 总是为空?????

时间:2005-04-28

来源:互联网

<:(SCRIPT language=JavaScript>
function reloadForm()
{
   var xmldoc= new ActiveXObject("MSXML2.DOMDocument");
   var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  
   xmldoc.async = false;
   var post=" ";
   xmlhttp.open("POST","<%=path%>/showList.do",false);   
   xmlhttp.setRequestHeader("Content-Type","text/xml");
   xmlhttp.setRequestHeader("Content-Type","gb2312");   
   xmlhttp.send(post);     
   alert(xmlhttp.Status+xmlhttp.StatusText);
   document.open(); document.close();
  var res=xmlhttp.responseXML;  
  xmldoc.load(res);
  alert(xmldoc.xml);
}   
</SCRIPT>



alert(xmlhttp.Status+xmlhttp.StatusText);  返回200OK

作者: qq123qq321   发布时间: 2005-04-28

可以试试xmlhttp.responseStream

作者: zhangshying   发布时间: 2005-04-28

也可以试试
xmlhttp.responseText 调试看看post过去的页面有没有什么错误..

作者: Eclipse   发布时间: 2005-05-17

直接显示xml呢?
           alert(xmlHTTP.responseXML.xml);
或试试 utf-8 .

作者: ※潇洒※   发布时间: 2005-05-28

才在老外网站找到答案.说的是asp ,不知道对你这个有没帮助?
If the response was generated by an ASP page, and the MIME type was not correctly set to 'text/xml', responseXML will be empty.

作者: ※潇洒※   发布时间: 2005-05-28

多谢※潇洒※兄,真的是这个原因啊,要在服务器端把content-type设置为“text/xml”就解决了,崇拜崇拜:))))

BTW:与编码无关,:P:

[ 本帖由 guo_q 最后编辑于 2005-9-7 10:37 ]

作者: guo_q   发布时间: 2005-09-07