我正在通过jquery ajax解析一些xml。除了IE之外,我的所有浏览器都有很好的工作。与IE浏览器的Jquery Ajax
我已经缩小到IE挂起的位置,我不知道如何解决它。我不知道是否这是我用来获取html的jquery的问题,或者如果它是我的xml的问题,或者它是我忽略的东西。有趣的是,当我提醒我的变量持有xml数据时,IE会正确地警告所有信息,但它似乎无法正确地遍历它并格式化数据。请帮忙。
这里是我使用从我的XML提取数据的代码:
function parseXML (data) {
$(data).find("section").each(function() {
var $section = $(this),
photos = $section.find("photo"),
photoContainer = $("<div></div>", {
id: $section.attr("id"),
"class": "gallery-section"
});
photos.each(function() {
var photo = $(this),
imageurl = photo.attr("imageurl"),
title = photo.find("title").text(),
description = photo.find("description").html(),
kind = photo.find("description").attr("type");
icon = photo.find("icon").attr("source");
iconClass = photo.find("icon").attr("class");
var photoWrapper = $("<div class='photo'></div>"),
imageElem = $("<img />", {
"src": imageurl,
"class": "gallery-photo"
}),
photoInfo = $("<div></div>", {
"class": "photo-info " + kind
}),
iconInsert = $("<img />", {
"src": icon,
"class": iconClass
}),
header = $("<h1></h1>", {
text: title
}),
photoDescription = $("<div></div>", {
html: description
});
photoInfo.append(iconInsert).append(header).append(photoDescription);
photoWrapper.append(imageElem).append(photoInfo);
photoContainer.append(photoWrapper);
});
$("#photo-viewer-inner").append(photoContainer);
});
var videos = "<div id='videos'></div>";
$("#photo-viewer-inner").append(videos);
$("#videos").load("images/gallery-images/videos.html #video-inner");
}
/* Get Photos From XML */
var dataType;
if ($.browser.msie) {
dataType = "text";
} else {
dataType = "html";
}
$.ajax({
type: "GET",
url: "images/gallery-images/gallery-images.xml",
dataType: dataType,
success: function(data, status)
{
parseXML(data);
alert(data);
},
});
IE悬挂在哪里?而且,你是否尝试过'dataType:xml'? – 2012-03-19 21:19:05
IE到达函数'parseXML'的第2行时挂起。它似乎得到的XML文件的内容很好,但它不能遍历它们并提取我需要的数据。是的,我试着用多种不同的组合来改变dataTypes和contentTypes。没有这样的运气。 – jcbfshr 2012-03-19 21:23:04
不能使用“class”作为var或属性名称,大多数浏览器接受它,但不应该。 – Dampsquid 2012-03-19 21:25:55