0
我有IE6的問題,即從XML即使我剝離HTML把這個包內CDATAjQuery IE6從XML剝離HTML。
如<name>Product <![CDATA[<br />]]> Name</name>
var phoneCarousel = $("#phone-carousel"), phoneXmlPath = "deals/phones.xml";
// Generate to allow image to be vertial aligned bottom.
function generateTable(name, image){
var table = '<table cellspacing="0" cellpadding="0">';
table += '<tr><td class="img"><img alt="'+name+'" src="'+image+'"></td></tr>';
table += '<tr><td>'+name+'</td></tr>';
table += '</table>';
return table;
}
phoneCarousel.addClass("loading");
// Get Phones XML
$.ajax({
type: "GET",
url: phoneXmlPath,
dataType: "xml",
contentType: "application/xml; charset=utf-8",
success: function(xml){
phoneCarousel.html("");
//This function will loop for each match on phones/phone
$(xml).find("phone").each(function(index, value){
var tis = $(this), first = '';
if(index == 0){
first = ' class="selected"';
}
phoneCarousel.append('<li'+first+'>' + generateTable(tis.find("name").text(), tis.find("thumbnail").text()) + '</li>');
});
phoneCarousel.removeClass("loading");
},
error:function(xhr,type){
if(type == null){
var errorMsg = "There was an error loading the phone.xml file!<br/>Please make sure the path to the xml file <strong>'"+phoneXmlPath+"'</strong> is correct.";
}else if(type == "parsererror"){
var errorMsg = "There is an error in the file <strong>'"+phoneXmlPath+"'</strong>.";
}else{
var errorMsg = "An error has been detected.";
}
phoneCarousel.removeClass("loading").html("<p><strong>Error:</strong> "+errorMsg+"</p><p><strong>Type of error:</strong> "+type+".</p>");
}
});
嘗試使用text/xml代替application/xml作爲內容類型,IE對內容類型非常嚴格。 –
解決了它,謝謝。 –
我會將它移動到您的答案,以便可以清除問題。 –