jQuery, AJAX and Internet Explorer


The issue:

Internet Explorer won’t parse XML quite as easily as every other browser on the internet (I assume). You have to change what you pass it as through jQuery. In IE it has to be passed as text, while the rest can handle it as XML. You also have to pass it through a separate function that brings in ActiveX before you can navigate your way through the XML and use it in your application.

The solution:

Set the type to “text” for IE and “xml” for the rest.

dataType: ($.browser.msie) ? "text" : "xml"

Use a function to “fix” the XML for IE

function parseXml(xml) {
 if (jQuery.browser.msie) {
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.loadXML(xml);
    xml = xmlDoc;

    }

 return xml;
}

Reference the function in your .ajax()

success: function(xml) {

var newXML = parseXml(xml);

$(newXML).find()....

here we go!

Yazar : Emre Macit (254 Posts)

Ideasoft yazılım departmanı ve Ar-ge sorumlusu. Matematik mühendisi. İnternet üzerine, yazılım ve koda dair her şey hakkında araştırma yapmayı ve bunları denemeyi seviyor. Yazılıma dair yazılar ağırlıklı olmakla birlikte arama motorları, sosyal medya ve teknolojiyle ilgili diğer konularda da yazılar yazıyor. Bazı konular için vakit bulamamaktan şikayetçi..

O da yazılımcı.

  1. Henüz hiç yorum yok.
(yayınlanmayacak)


%d blogcu bunu beğendi:
ubuntu’ya ruby kurulumu

Ruby kurulumunda 2 seçenek var. Biri RVM olmadan, biri RVM ile. ( RVM = Ruby Version Manager ) RVM olmadan...

Kapat