简体   繁体   中英

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!

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();
}});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM