关于ajax异步加载XML例子

//首先上xml文件

<?xml version="1.0" encoding="utf-8" ?>
<Info>
  <User id="1">
    <name>陶国荣</name>
    <sex></sex>
    <email>tao_guo_rong@163.com</email>
  </User>
</Info>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#Button1").click(function () {
                $.get("UserInfor.xml", function (data) {
                    $("#divTip").empty();//先清空标记中的内容
                    var strHTML = "";
                    $(data).find("User").each(function () {
                        var $strUser = $(this);
                        strHTML += "姓名:" + $strUser.find("name").text() + "<br/>";
                        strHTML += "性别:" + $strUser.find("sex").text() + "<br/>";
                        strHTML += "邮箱:" + $strUser.find("email").text() + "<br/>";
                    });
                    $("#divTip").html(strHTML); //显示
                });
            });
        })
    </script>
</head>
<body>
    <input type="button" id="Button1"  value="ajax异步载入数据" />
    <div id="divTip">

    </div>
</body>
</html>

//效果:

说明:

原文地址:https://www.cnblogs.com/yzenet/p/3119095.html