JQuery加载DIV中的外部页面

JQuery to load external pages in DIV

本文关键字:外部 加载 DIV JQuery      更新时间:2023-09-26

我正在使用jquery加载index.html中的外部页面菜单链接具有功能-关于

function about() {jQuery('#container').load('about.html');}

我在每个子页面上使用jquery函数从xml中获取数据。显然,我在index.html上只调用了一次jquery,并对child使用了same,它的工作方式不同。当我单击它时,它清空了#container,但没有外部文件数据。但当我双击菜单选项卡时,我会看到数据。我真的很失落,需要帮助来弄清楚我做错了什么。hashworld.com.au/test/test.html我已经在这里上传了代码,请看一下

在rules.html中尝试更改:

<script src="js/xmlConfig.js"></script>
<script>
    function parseXml(xml){
        $(xml).find("rules").each(function(){
        $(xml).find("rule").each(function(){
            var rule = $(this).text();
            $('<li></li>').html(rule).appendTo('.content ul');
        });
      });
    }
</script>

进入这个:

<script>
$(document).ready(function()
{
  $.ajax({
    type: "GET",
    url: "xml/global_webconfig.xml",
    dataType: "xml",
    success: parseXml
  });
  function parseXml(xml){
        $(xml).find("rules").each(function(){
        $(xml).find("rule").each(function(){
            var rule = $(this).text();
            $('<li></li>').html(rule).appendTo('.content ul');
        });
      });
  }
});
</script>