jQuery IE6 извлекает HTML из XML. - PullRequest
0 голосов
/ 28 сентября 2011

У меня проблема с IE6, который удаляет HTML из XML, даже после того, как я обернул это внутри CDATA

например <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>");       
        }           
    });

1 Ответ

1 голос
/ 28 сентября 2011

Попробуйте использовать text/xml вместо application/xml в качестве типа контента, IE очень строг с типами контента.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...