json问题:在页面不显示

echola_2020 2012-03-22 12:01:48
用jquery easyui 做的。 现在的问题是json数据在页面上不显示。后台用Struts已经转换为json了
PrintWriter out=ServletActionContext.getResponse().getWriter();
ServletActionContext.getResponse().setContentType("Content-type:text/xml;charset=UTF-8");
out.print(listJson);
out.flush();
前台获取json:
<table id="tt" class="easyui-datagrid"
url="searchBooktoM",
dataType="json",
title="Searching" iconCls="icon-search" toolbar="#tb"
rownumbers="true" pagination="true">
<thead>
<tr>
<th field="bookIndex" width="80">索书号</th>
<th field="bookName" width="80">书名</th>
<th field="bookAuthor" width="120">作者</th>
<th field="bookPress" width="80" align="right">出版社</th>
<th field="bookPrice" width="80" align="right">价格</th>
<th field="" width="60" align="center">操作</th>
</tr>
</thead>
</table>
如果把后台打印的json数据存为*.json文件,前台的url指向json,可以显示数据。
是什么问题?
...全文
319 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
<table id="tt" class="easyui-datagrid"
url="searchBooktoM",
dataType="json",
title="Searching" iconCls="icon-search" toolbar="#tb"
rownumbers="true" pagination="true">

没见过这样获取json的。
得用ajax请求回调来做显示
冰镇宝贝321 2012-03-23
  • 打赏
  • 举报
回复
firebug 调试。 按楼上的小哥说的试试
色拉油 2012-03-22
  • 打赏
  • 举报
回复
页面获取后得自己写显示,要不人家怎么知道你想显示什么
hch126163 2012-03-22
  • 打赏
  • 举报
回复
firebug 调试。看看你获取到是格式是否有问题啊
吉普赛的歌 社区高级成员 T9 2012-03-22
  • 打赏
  • 举报
回复
你先将取得的json , 能用一个循环, document.write出来了, 再说吧
吉普赛的歌 社区高级成员 T9 2012-03-22
  • 打赏
  • 举报
回复
不需要展示来展示去, 你要先看你取得的json, 是否是真正的json.
一般后台取的json, 都是string, 要
var json=eval(str); //转一次的
echola_2020 2012-03-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 acesidonu 的回复:]

前台是否获得了正确的 数据
[/Quote]
用什么可以判断前台是否有了数据?
Acesidonu 2012-03-22
  • 打赏
  • 举报
回复
前台是否获得了正确的 数据
m540920181 2012-03-22
  • 打赏
  • 举报
回复
恩,你要使用方法,把他们打印出来

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧