後臺java代碼java
@RequestMapping("/cameraList") @ResponseBody public Map<String, Object> cameraListForPage(@RequestParam(defaultValue = "1", value = "page") Integer page , @RequestParam(defaultValue = "10", value = "limit") Integer limit , String storageCenterId, String startDate,String endDate) { Map<String, Object> parameter = new HashMap<>(16); parameter.put("storageCenterId", storageCenterId); parameter.put("page", (page - 1) * limit); parameter.put("limit", 99999); parameter.put("isExist", 1); Map<String, Object> map = new HashMap<>(16); // 統計列表條數 List<MonitorBaseInfo> resultList = monitorBaseInfoService.getAllMonitorBaseInfoListForPage(parameter); // 測試 MonitorBaseInfo m = resultList.get(0); String data = HikvisionUtil.getCameras(m.getLoginUsername(), m.getLoginPassword(), m.getIp(), m.getPort(), page, limit); String result = HikvisionUtil.getStringData(data); Integer countTotal = HikvisionUtil.getCountCamera(data); if (countTotal > 0) { map.put("code", 0); map.put("msg", "獲取視頻成功"); map.put("count", countTotal); map.put("data", result); } else { map.put("code", 0); map.put("msg", "暫無數據"); map.put("count", countTotal); } return map; }
頁面ajax代碼:ajax
$.ajax({ type:"get", url:"/monitorManage/cameraList", success:function(result){ //解決數據疊加問題 var data = JSON.parse(result); $('.vs-list').empty(); var list = JSON.parse(data.data); list.forEach(function(item){ console.log(item); var id = item.cameraUuid; var name = item.cameraName; //var videoUrl = item.videoUrl; //var data = item.data; //var time = item.time; //var week = item.week; var type = item.cameraType; 其餘業務處理……
注意
var data = JSON.parse(result); 此處不轉json獲取不到之值,
var list = JSON.parse(data.data); 不轉json獲取不到之值,
不轉json獲取不到之值!!!json
result.code or result.msg or result.data或者是
result["code"],result["msg"],result["data"]都獲取不到值。
緣由不詳,用的layui框架!app