如何将接口返回内容展示在列表中
新手求助, 我有一个接口请问如何才能将url返回的内容循环出来
请求地址http://ip:8001/?_a=getmedia&page=<%=CurrentPage%>&begin_time=2017-09-20
实例:
实例:
{
"header": {
"state": "success",
"count": 1
},
"body": [
{
"data_id": "107",
"capture_date": "2017-09-20 13:38:11",
"device_no": "00027892",
"creation_date": "2017-09-20 13:35:19",
"media_name": "00027892@201709201338110000",
"file_name": "\u7701\u98df\u836f\u76d1\u5c40@201709201338110000",
"police_no": "00001",
"org_no": "10014",
"org_name": "\u79d1\u6280\u6807\u51c6\u4e0e\u5ba3\u4f20\u5904",
"file_type": "JPG",
"serverurl": "FTPServer",
"playposition": "media\/20170920\/JPG\/00027892@201709201338110000.JPG",
"thumb": "media\/20170920\/JPG\/00027892@201709201338110000.THM.JPG",
"file_length": "5.86",
"file_duration": null,
"media_desc": null,
"upload_station_ip": "q1691g9709.imwork.net:10000",
"upload_station": "ZCS-JLYW57080035",
"media_play_url": null,
"source_type": null,
"thumburl_def": "",
"thumburl": "http:\/\/221.208.28.175:8001\/media\/20170920\/JPG\/00027892@201709201338110000.THM.JPG",
"playurl": "http:\/\/221.208.28.175:8001\/media\/20170920\/JPG\/00027892@201709201338110000.JPG"
}
]
}
这是我自己写的不知道哪里不对,第一次接触
$.ajax({
type:"GET",
url :"http://ip:8001/?_a=getmedia&page=1&begin_time=2017-09-20",
dataType:"json",
async:true,
contentType:"application/json",
cache:false,
success:function(data){
var result ="";
for(var i=0; i<data.content.lenght;i++){
var da=data.content[i];
result+= "<tr>" +
" <td style=\"width: auto;\">" + da.data_id + "</td>" +
" <td style=\"text-align: center;\">" + da.police_no + "</td>" +
" <td style=\"width: auto; text-align: center;\">" + da.org_name + "</td>" +
" <td style=\"width: auto; text-align: center;\">" + da.device_no + "</td>" +
" <td style=\"width: auto; text-align: center;\">" + da.capture_date + "</td>" +
" <td style=\"width: auto; text-align: center;\">" + da.file_type + "</td>" +
" <td style=\"width: auto; text-align: center;\">" + da.media_desc + "</td>" +
"</tr>";
}
},
error:function(result){
}
})