zoukankan      html  css  js  c++  java
  • JQuery AJAX 解析获得的JSON数据

    下面的解析的Json是一个二级循环。

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script>
    $(document).ready(function(){
      $("button").click(function(){
        $.ajax({
            type: "get",
            url: "http://xx.xx.yy/zz",
            beforeSend: function(XMLHttpRequest){
                //ShowLoading();
            },
            success: function(data, textStatus){
                $("#info").html("");
                $.each(data, function(i,item){
                      $("#info").append(
                          "<div><b>" + item.pid + "</b></div>" +
                          "<div><b>" + item.name + "</b></div>"
                          
                      );
                      $(data[i].children).each(function(){
                          $("#info").append(
                          " <div>" + this['id'] + "</div>" +
                          " <div>" + this['name'] + "</div>" +
                          " <div>" + this['pup'] + "</div>"
                          
                      );
                      
                     
                          
                          });
                    });
                
            },
            complete: function(XMLHttpRequest, textStatus){
                //HideLoading();
            },
            error: function(){
                //请求出错处理
            }
    });
    
      });
    });
    </script>
    </head>
    <body>
    
    <button>解析Json</button>
    <p id="info">Info</p>
    </body>
    </html>
  • 相关阅读:
    数据库 连接(join)
    Linux top
    Game2048
    黑豆白豆问题
    1000个苹果10箱
    Jconsole
    八数码 Java实现
    两数之和
    磁盘调度算法
    常见应用网络层次
  • 原文地址:https://www.cnblogs.com/linlf03/p/5555863.html
Copyright © 2011-2022 走看看