我正在尝试向返回 XML 文档的 ASPX 页面发出 jQuery $ajax GET 请求,但无法使其正常工作。我究竟做错了什么?
jQuery
$(document).ready(function() {
$("#loading").show();
$.ajax({
type: "GET",
url: "http://www.url.com/reports/xml.aspx",
dataType: "xml",
success: parseXml
});
function parseXml(xml) {
$(xml).find("Year").each(function() {
$("body").append( $(this).find("RevenueYear").text() + '<br />' });
}});
HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
<strong>XML
<root>
<Year>
<RevenueYear>2011</RevenueYear>
<RevenueType>actual</RevenueType>
</Year>
<Year>
<RevenueYear>2012</RevenueYear>
<RevenueType>estimate</RevenueType>
</Year>
</root>