{
"AreaMax":
{
"schema":[
{"name":"AREA","type":"string"},
{"name":"ADCD","type":"string"},
{"name":"VAL","type":"decimal"},
{"name":"STNM","type":"string"},
{"name":"row","type":"long"}
],
"data":[
{"AREA":"洪洋乡","ADCD":"350123201000000","VAL":"2.0","STNM":"厝坪-气象","row":"1"},
{"AREA":"霍口畲族乡","ADCD":"350123203000000","VAL":"1.0","STNM":"斌溪水库-防汛","row":"1"},
{"AREA":"白塔乡","ADCD":"350123200000000","VAL":"1.0","STNM":"苏区水库-水文","row":"1"},
{"AREA":"凤山镇","ADCD":"350123100000000","VAL":"1.0","STNM":"罗源-防汛","row":"1"},
{"AREA":"松山镇","ADCD":"350123101000000","VAL":"1.0","STNM":"松山围垦-防汛","row":"1"},
{"AREA":"西兰乡","ADCD":"350123202000000","VAL":"0.0","STNM":"洋坪-防汛","row":"1"},
{"AREA":"鉴江镇","ADCD":"350123105000000","VAL":"0.0","STNM":"碧里-气象","row":"1"}
]
}
,"AreaAvg":
{
"data":[
{"AREA":"洪洋乡","AVGVAL":"1"},
{"AREA":"霍口畲族乡","AVGVAL":"0.5"},
{"AREA":"白塔乡","AVGVAL":"0.5"},
{"AREA":"凤山镇","AVGVAL":"0.5"},
{"AREA":"松山镇","AVGVAL":"1"},
{"AREA":"西兰乡","AVGVAL":"0.0"},
{"AREA":"鉴江镇","AVGVAL":"0.0"}
]
}
}
以上是数据源
javascript 获取jason值
var jsonData;
$.ajax({
type: "Get", //请求的方法
url: "../public/dataaccess/rain/RainAreaMaxDataProvider.ashx?adomParameter=" + Math.floor(Math.random() * 1000 + 1), //要传递参数使用Ajax进行处理的类名称
dataType: "text", //返回的数据类型
global: false, //Ajax的范围
async: false, //异步执行
//成功情况下的处理
success: function (strReult) {
jsonData=eval("("+strReult+")");
// var f= jsonData.AreaMax.data[0].AREA;
}, //失败情况下的处理
error: function () {
alert("Ajax请求数据失败!");
}
});
//循环读取
for(var i=0;i<jsonData.AreaMax.data.length;i++){
rainAreaMaxHtml+=jsonData.AreaMax.data[i].AREA+jsonData.AreaMax.data[i].STNM+jsonData.AreaMax.data[i].VAL;
}