views:

28

answers:

1

XML reading using jQuery is not working in ie6 and ie8. i've used the below code.. the alert is not coming in ie8, ie6, i've not tested with other internet explorer versions.

$(document).ready(function()
{
    $.ajax({
        type: "GET",
        url: "xml/contextMenu.xml",
        dataType: "xml",
        success: function(xml) {
            alert('hi');            
        }
    });
});

but it is working in mozilla firefox 3.6.3. Anybody has any idea what may be the problem... Please help me...

A: 

try this before you start the $.ajax() statement

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

then, in success, add: var newXML = parseXML(xml);

change your references of xml to newXML and you should be good.

Cru