zoukankan      html  css  js  c++  java
  • jquery 读取xml数据示例

    1. <html>   
    2. <head>   
    3. <title>jquery xml解析</title>   
    4. <script type="text/javascript" src="js/jquery-1.3.2.js"></script>   
    5. <script type="text/javascript">   
    6.     $(document).ready(   
    7.             function() {   
    8.                 $.ajax( {   
    9.                     url : "xx.xml",   
    10.                     success : function(xml) {   
    11.                         $(xml).find("province").each(function() {   
    12.                             var t = $(this).attr("name");//this->      
    13.                                 $("#DropProvince").append(   
    14.                                         "<option>" + t + "</option>");   
    15.                             });   
    16.                     }   
    17.                 });   
    18.                 $("#DropProvince").change(   
    19.                         function() {   
    20.                             $("#sCity>option").remove();   
    21.                             var pname = $("#DropProvince").val();   
    22.                             $.ajax( {   
    23.                                 url : "xx.xml",   
    24.                                 success : function(xml) {   
    25.                                     $(xml).find(   
    26.                                             "province[name='" + pname   
    27.                                                     + "']>city").each(   
    28.                                             function() {   
    29.                                                 $("#sCity").append(   
    30.                                                         "<option>"  
    31.                                                                 + $(this)   
    32.                                                                         .text()   
    33.                                                                 + "</option>");   
    34.                                             });   
    35.                                 }   
    36.                             });   
    37.                         });   
    38.             });   
    39. </script>   
    40. </head>   
    41. <body>   
    42. <form id="form1">   
    43. <div>   
    44.     <select id="DropProvince" style=" 60px;">   
    45.         <option>请选择</option>   
    46.     </select>   
    47.     <select id="sCity" style=" 60px;">   
    48.     </select>   
    49. </div>   
    50. </form>   
    51. </body>   
    52. </html>  
  • 相关阅读:
    Linux基础命令—网卡
    SHOW SLAVE STATUS解读
    perf工具crash的问题
    python学习之-requests模块基础
    DELL IDRAC API接口开发文档翻译及client模块
    cobbler ks文件解释--转载
    django学习之- 动态验证码学习
    django学习之- Ajax
    django学习之- modelForm
    django学习之- json序列化
  • 原文地址:https://www.cnblogs.com/xie/p/1752769.html
Copyright © 2011-2022 走看看