0
有人能帮助我并指出我错在哪里。感谢你的帮助。网格显示空白,没有任何东西正在加载。JqGrid无法从PHP的JSON格式加载数据
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.1.1/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.1.1/js/jquery.jqGrid.src.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list2").jqGrid({
url:'http://localhost/jqgrid/book.php',
datatype: "json",
colNames:['Title', 'Author', 'Publisher'],
colModel:[
{name:'title' , width:160},
{name:'author' ,width:180},
{name:'publisher' ,width:80}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'title',
sortorder: "desc",
height: 'auto',
width: 900,
viewrecords: true,
gridview: true,
caption:"JSON Example",
jsonReader : {
repeatitems: true,
cell: "cell",
id:"id",
userdata: "userdata",
root: "rows",
page: "page",
total: "total",
records: "records"
}
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:true,del:true});
});
</script>
</head>
<body>
<table id="list2"><tr><td></td></tr></table>
<div id="pager2"></div>
</body>
</html>
这里从PHP我的JSON响应:
{ “页”: “1”, “总”:1, “记录”: “2”, “行”:[{ “ID” :“2”,“cell”:[“PHP QUERY”,“JSON”,“VTECH”]},{“id”:“1”,“cell”:[“JQUERY Cook book”,“MY AUTHOR”, “GRID”]}]}