问题描述
XML:
<?xml version="1.0"?>
<choices>
<choice>
<start>39</start>
<duration>6</duration>
<path>
<name></name>
<complete></complete>
</path>
<path>
<name></name>
<complete></complete>
</path>
</choice>
</choices>
$.ajax({
url: 'choices.xml',
context: this,
async: false,
success: function(response) {
var xmlDoc = $.parseXML(response);
console.log(xmlDoc); // null
}
});
XML 被报告为有效,并且没有引发错误.我知道我可以使用 $(response),但我不需要它.
The XML is reported as valid, and no error is thrown. I know I can use $(response), but I don't need that.
- jQuery 1.7.2
推荐答案
数据类型
默认值:智能猜测(xml、json、脚本或 html)
dataType
Default: Intelligent Guess (xml, json, script, or html)
xml":返回一个可以通过 jQuery 处理的 XML 文档.
"xml": Returns a XML document that can be processed via jQuery.
$.ajax() 函数依赖于服务器来提供有关检索数据的信息.如果服务器将返回数据报告为 XML,则可以使用普通的 XML 方法或 jQuery 的选择器来遍历结果.如果检测到其他类型,例如上例中的 HTML,则将数据视为文本.
The $.ajax() function relies on the server to provide information about the retrieved data. If the server reports the return data as XML, the result can be traversed using normal XML methods or jQuery's selectors. If another type is detected, such as HTML in the example above, the data is treated as text.
结果应该已经被解析了.
The result should already be parsed.
如果您特别不想对其进行解析,请使用不同的 dataType.
If you specifically don't want it to be parsed, use a different dataType.
这篇关于$.parseXML 不适用于有效的 xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!




大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)