数据库:
1.前端处理方式:
//后台返回的json字符串:
<pre name="code" class="javascript">var data ="[{"fatherId":0,"sonId":9999,"name":"中国"},{"fatherId":1,"sonId":0,"name":"湖北省"},{"fatherId":2,"sonId":1,"name":"武汉市"},{"fatherId":3,"sonId":1,"name":"咸宁市"},{"fatherId":4,"sonId":3,"name":"崇阳县"},{"fatherId":5,"sonId":3,"name":"温泉区"},{"fatherId":6,"sonId":2,"name":"江岸区"},{"fatherId":7,"sonId":2,"name":"江夏区"},{"fatherId":8,"sonId":0,"name":"湖南省"},{"fatherId":9,"sonId":8,"name":"长沙市"}]";
//前端处理:
var node = { id: _data[0].fatherId, pid: _data[0].sonId, text: _data[0].name, children: [] };
getAreaTree(_data, node);
function getAreaTree(data,pnode)
{
var _Name = [];
var temp = {id:"",pid:"",text:"",children:[]};
for (var i = 0; i < data.length; i++)
{
if (data[i].sonId == 0 && pno