当前位置: 代码迷 >> Ajax >> 怎么用responseText接收一个xml格式的字符串
  详细解决方案

怎么用responseText接收一个xml格式的字符串

热度:208   发布时间:2012-07-24 17:47:58.0
如何用responseText接收一个xml格式的字符串?
大家新年好,问个问题。
AJAX如何接收一个xml形式的字符串?
比如服务端返回的是
"<abc><aaa>AJAX</aaa></abc>"
我想在客户端接收的也是上面这个字符串.


------解决方案--------------------
你设置response.ContentType="text/plain"
返回的结果就可以直接使用responseText接收了
------解决方案--------------------
你是怎么写的代码啊,很简单啊

1.htm

HTML code
<script>
x = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("MSXML2.XMLHTTP");
x.open("GET","a.asp",false)
x.send(null);
alert(x.responseText)
</script>