Ajax 请求和 text/xml
我通过 ajax 请求 xml 文件,服务器使用 header text/xml 作为返回的数据。 Firefox 读取此标头并将数据转换为 XMLDocument 对象,这意味着我无法将其与 jQuery 一起使用。 如何获取纯文本形式的 XML 文档?
I am requesting and xml file over ajax, the server uses the header text/xml for the data returned. Firefox reads this header and turns the data into an XMLDocument object which means I can't use it with jQuery. How can I get my XML document as plain text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
返回的
xmlHttp
对象有一个responseXML属性。 这映射到 XmlDocument。 如果您阅读本文档子节点的textContent
,您将能够检索纯文本响应。例如:
或者,您可以访问responseText属性以获取字符串形式的整个响应:
The
xmlHttp
object returned has a responseXML property. This maps to an XmlDocument. If you read thetextContent
of the childnodes of this document, you will be able to retrieve the plain text response.For instance:
Alternatively, you can access the responseText property to get the entire response as a string:
通过序列化修复它:
Fixed it by serializing: