easyui中datagrid显示数据的时候报Cannot read property 'length' of undefined
来源:互联网 发布:调度数据网 编辑:程序博客网 时间:2024/05/18 02:15
最近在搭一个框架,页面开发完后,发现没有数据显示,经查询是因为js报错了,错误信息如下:
Cannot read property 'length' of undefined
进一步查看原因,是因为rows.length报的错,说明没有rows这个变量,但是查看后台代码是有数据返回的,后台部门代码如下:
Map<String, Object> map = new HashMap<String, Object>();map.put("total", userPage.getRecordSum());map.put("rows", userPage.getRecordList());String result = JSONObject.toJSONString(map);
这是在另外一个框架中复制出来的代码,之前一直用着也没有发现问题。后来在网上查询相关文章后,意识到js中处理的参数必须是JSON对象,而不能是JSON格式的字符串,而我这边恰恰是转换成字符串后返回的,如果没有在js中使用JSON.parse(str)转换的话,就无法读取,后来修改后台代码后解决了问题,代码如下:
Map<String, Object> map = new HashMap<String, Object>();map.put("total", page.getRecordSum());map.put("rows", page.getResults());return map;
因为在方法上面加了@ResponseBody,所以map就被转换成JSON对象返回到页面了,这样js中就能正常读取了。
阅读全文
0 0
- easyui中datagrid显示数据的时候报Cannot read property 'length' of undefined
- easyui列表查询报错:Cannot read property 'length' of undefined
- easyui列表查询报错:Cannot read property 'length' of undefined
- 解决jquery报错cannot read property 'length' of undefined
- react native 报错:cannot read property 'length' of undefined
- jQuery EasyUI 报错:Cannot read property length of XXX
- easyui reload方法报Cannot read property 'options' of undefined
- Cannot read property 'length' of undefined
- datagrid报Cannot read property '' of null
- Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError Cannot read property 'length' of undefined
- JQUERY提示Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined
- js的form(load报错jquery.easyui.min.js:2837 Uncaught TypeError: Cannot read property 'tip' of undefined
- easyui防止重复提交及进度条报错解决: Cannot read property 'onClose' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined出现的问题
- EasyUI Window Cannot read property 'options' of undefined
- MongoDB简介和基本概念(一)
- C++静态初始化的顺序
- Poj 2689 Prime Distance(素数筛+二次素数筛)
- oracle注册表删除--彻底卸载Oracle
- IndentationError: unexpected indent python
- easyui中datagrid显示数据的时候报Cannot read property 'length' of undefined
- Android中Bitmap的加载和Cache(三级缓存 :LruCache,DiskLruCache)学习笔记
- mysql57 windows zip install
- ssh-keygen的详解----本人亲自验证过
- Fiddler实现手机抓包——风云无忌
- pthread_cond_broadcast()
- CAS4.2.7 的 php 客户端1.3.5 的简单实践
- IC设计基础系列之低功耗篇5:(数字IC)低功耗设计入门(五)——RTL级低功耗设计(续)
- MySQL优化