下面的解析的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>