我已经查看并尝试了有关 jQuery、XML 和 IE8 的所有 SO 答案,但没有任何结果。关于如何让它与 jQuery 或 Javascript 一起工作的任何其他建议?
$.ajax({
type: "GET",
url: "http://query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.fs.usda.gov%2Fwps%2FPA_WIDConsumption%2Frssgetfile%3FxFSENavChannel00%3D1109%26xFSENavChannel02%3D091000000000000%26pathinfo%3D%2Fwps%2Fportal%2Ffsinternet%2F!ut%2Fp%2Fc5%2F04_SB8K8xLLM9MSSzPy8xBz9CP0os3gjAwhwtDDw9_AI8zPwhQoYAOUjzeINcABHAwK6w0H2YaoI84GrAMvjMd_PIz83Vb8gN8Igy8RREQC1scDO%2Fdl3%2Fd3%2FL2dJQSEvUUt3QS9ZQnZ3LzZfMjAwMDAwMDBBODBPSEhWTjJNMDAwMDAwMDA!%2F%3Fnavtype%3DBROWSEBYSUBJECT%26forestname%3DRegion%25209%22",
dataType:"xml",
success: function(msg){
data = parseXml(msg);
$(data).find('item').each(function(index,val){
var title = $(this).find("title").text();
var link = $(this).find("link").text();
$('#loadnews').append("<li><a href="+link+">"+title+"</a></li>");
});
}
});
function parseXml(xml) {
if ($.browser.msie && parseInt($.browser.version, 10) === 8) {
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(xml);
xml = xmlDoc;
}
return xml;
}
if ($.browser.msie && parseInt($.browser.version, 10) === 8) {
alert('IE8');
} else {
alert('Non IE8');
}
小提琴在这里:http: //jsfiddle.net/tjbLf/7/