mxch
mxch

Reputation: 865

Issue loading XML into DIV using JavaScript in IE

I need to load a configuration XML into a DIV, for that I'm using the following code:

    $(document).ready(function(){
                    console.log("Document ready");
        $("#footer_config").load("/config/footer_config.xml");
    });

This code works ok in Chrome but it doesn't in IE. It prints "Document ready" in the console but the "footer_config" DIV is empty. If I press CTRL+F5 in IE it works and the div has the content of the XML file. I'm using IE 9.

Any ideas?

Thanks in advance!

Upvotes: 1

Views: 361

Answers (1)

Jiskiras
Jiskiras

Reputation: 84

Try this:

$(function(){
    console.log("Document ready");
    $("#footer_config").load('/config/footer_config.xml', function() {
        console.log('Load finished');
    });
});

This will tell you that the load is complete. Try checking the network tab in the Chrome developer tools afterwards to see if it was even pulled down.

Update:

Instead of using the load method, try pulling it down with the AJAX method:

$.ajax({url: '/config/footer_config.xml', dataType: 'xml', cache: false, success: function(d) {
    console.log(d);
    $('#footer_config').html($(d).html();
}});

Upvotes: 1

Related Questions