簡體   English   中英

在IE中使用JavaScript將XML加載到DIV中的問題

[英]Issue loading XML into DIV using JavaScript in IE

我需要將配置XML加載到DIV中,為此,我正在使用以下代碼:

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

這段代碼在Chrome中可以正常運行,但在IE中則不能。 它在控制台中打印“ Document ready”,但“ footer_config” DIV為空。 如果我在IE中按CTRL + F5,則它可以正常工作,並且div具有XML文件的內容。 我正在使用IE 9。

有任何想法嗎?

提前致謝!

嘗試這個:

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

這將告訴您加載已完成。 之后,嘗試檢查Chrome開發者工具中的“網絡”標簽,以查看是否被拉下。

更新:

而不是使用load方法,請嘗試使用AJAX方法將其下拉:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM