• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

jqgrid+php应用问题

php 搞代码 3年前 (2022-01-23) 8次浏览 已收录 0个评论
文章目录[隐藏]

jqgrid有post动作到服务端,php文件里有写echo json_encode数据,数据post格式是json,用firebug查看,没有json数据返回,请问是什么原因呢

回复讨论(解决方案)

页面:

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
测试。。。。
<link rel=”stylesheet” type=”text/css” media=”screen” href=”/test/css/jquery-ui-1.7.2.custom.css” />
<link rel=”stylesheet” type=”text/css” media=”screen” href=”/test/css/ui.jqgrid.css” />
<script src=”/test/js/jquery-1.7.2.js” type=”text/javascript”></script>
<script src=”/test/js/grid.locale-cn.js” type=”text/javascript”></script>
<script src=”/test/js/jquery.jqGrid.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>
$(function(){
$(“#list”).jqGrid({
url:’d.php’,
datatype: “json”,
colNames:[‘编号’,’名称’],
colModel:[
{name:’sn’,index:’sn’},
{name:’tit¥本文来%源[email protected]搞@^&代*@码)网5搞gaodaima代码le’,index:’title’}
],
rowNum:10,
rowList : [20,30,50],
mtype: “POST”,
gridview: true,
pager: ‘#pager’,
caption: “Toolbar Searching….”,
jsonReader:{
repeatitems:false,
row: “rows”,
page: “page”,
total: “total”,
records: “records”
}
});
$(“#list”).jqGrid(‘navGrid’,’#pager’,{del:false,add:false,edit:false,search:false});
//$(“#list”).jqGrid(‘filterToolbar’,{stringResult: true,searchOnEnter : false});
});
</script>

<body>

程序:
<?php
$responce->page = 1;
$responce->total = 1;
$responce->records = 1;
$responce->rows[0][‘id’] = 1;
$responce->rows[0][‘cell’] = array (‘20130606′,’testdate…’);
echo json_encode($responce);
?>

控制台下看报什么错误了

程序改为以下:
$responce[“page”] = 1;
$responce[“total”] = 1;
$responce[“records”] = 1;
$responce[“rows”][0][“cell”] = array (“sn”=>”20130606″,”title”=>”testdate…”);
echo json_encode($responce);
用firebug可以看到有json数据返回,但在页面上为什么还是显示不了呢

没有报任何错误。。。,是不是还要引用什么包呢

把$responce->rows[0][‘cell’] = array (‘20130606′,’testdate…’);
改为$responce->rows[0] = array (‘20130606′,’testdate…’);
就可以了


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:jqgrid+php应用问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址