首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

基于Ajax技术用javascript和html编写一段代码

2013-06-19 
求助:基于Ajax技术用javascript和html编写一段代码新手求助:基于Ajax技术用javascript和html编写一段代码,

求助:基于Ajax技术用javascript和html编写一段代码
新手求助:基于Ajax技术用javascript和html编写一段代码,用下拉菜单来动态读取服务器上xml文件内容并显示在屏幕上。多谢大家指点!

<xml>
<employee>
<name>Norstar Times</name>
<location>Beijing</location>
<num>10</num>
</employee>
<employee>
<name>Norstar Media</name>
<location>Shaihai</location>
<num>10</num>
</employee>
</xml>
Ajax xml javascript html
[解决办法]
<script src="http://www.coding123.net/js/jquery.js"></script>
<script>
    $.ajax({
        dataType: 'xml',
        url: 'x.xml',//xml文件路径
        cache: false,
        success: function (dom) {
            var name, location, num;
            $('employee', dom).each(function () {
                name = $('name', this).text();
                location = $('location', this).text();
                num = $('num', this).text();
                alert(name + '\n' + location + '\n' + num);
            });
        },
        error: function (xhr) { alert('xml路径有问题~\n' + xhr.responseText); }
    });
</script>


上面是jq的,底层的参考这个:javascript xml

热点排行