2011-09-28 3 views
0

내가jQuery IE6에서 XML을 제거합니다.

예를 들어 <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>");  
     }   
    }); 
+2

콘텐츠 유형으로 application/xml 대신 text/xml을 사용하면 콘텐츠 유형이 매우 엄격합니다. –

+0

그 덕분에 해결되었습니다. –

+0

질문을 지울 수 있도록 답장으로 이동하겠습니다. –

답변

1

text/xml를 사용해보십시오 대신 컨텐츠 형식과 application/xml이 내부 CDATA 포장 심지어 후 XML에서 HTML을 제거한다 IE6에 문제가, IE는 매우 엄격하다 콘텐츠 유형.

관련 문제