我有很多jqGrid的工作示例,昨天我添加了一个新的例子。它在我的本地主机上工作正常,但当我将它移动到我的在线临时服务器时,我会得到加载屏幕,然后什么也没有。没有错误。
一些注意事项:
1)使用JSON,一次全部下载
2)在同一浏览器中在localhost中正常工作
3)HTML源代码看起来相同
4)JS源相同
5)JSON数据相同
6)登台服务器上的PHP 5.1,本地上的PHP 5.3
7)适用于Firefox 3(Linux和Windows上的Chrome 11中出现问题)
8)在我的其他jqGrid设置之前从未遇到过这种情况。
之前有人碰到这样的事吗?这真让我感到困惑,我不想开始调试jqGrid本身。
编辑: 这是我的jqGrid电话:
jQuery(function(){
jQuery('#list1').jqGrid({
url:'/index.php?option=com_coinnet&view=snap&layout=list&Itemid=123&format=json&ajax=1',
datatype: 'json',
mtype: 'GET',
colNames: ["ID","Date","Dealer","Amount","Check Number","Tracking Number","Deal Done","Note?","Date Sort"],
colModel: [{"name":"id","width":0,"hidden":true,"key":true},{"name":"date_postedstr","width":100,"align":"right","index":"date_posted"},{"name":"stationlink","width":100,"align":"right"},{"name":"amount","width":120,"align":"right","sorttype":"float","formatter":"number","formatoptions":{"decimalSeparator":".","thousandsSeparator":",","decimalPlaces":2}},{"name":"check_number","width":100,"align":"right"},{"name":"tracking_number","width":100,"align":"right"},{"name":"status","width":50,"sortable":false,"align":"right","formatter":"checkbox","formatoptions":{"disabled":"false"}},{"name":"link","width":60,"align":"right","formatter":"showlink","formatoptions":{"idName":"dealID","baseLinkUrl":"","addParam":"&option=com_coinnet&view=snap&layout=deal&Itemid=124"}},{"name":"date_posted","hidden":true,"width":0}],
pager: '#pager1',
loadonce:true,
rowNum:10,
rowList:[5,10,20,25,30,50,100,-1],
sortname: 'date_posted',
sortorder: 'DESC',
viewrecords: true,
caption: 'SNAP Deals',
multiselect:false,jsonReader : {
root:"data",
page: "currpage",
total: "totalpages",
records: "totalrecords",
repeatitems: false,
id: "0"
},
loadComplete: function() {
jQuery("option[value=-1]").text('All');
},
height: 'auto',
});
});
这是我的数据:
{"data":[{"id":"1654088","my_name":"CT00","my_id":"11920","other_name":"NV23","date_posted":"2010-12-07 14:23:34","check_number":null,"tracking_number":null,"notes":null,"shipped":"F","paid":"F","status":false,"amount":null,"check_number_date":null,"tracking_number_date":null,"newversion":"F","bulletin_id":null,"original_mailbox_id":null,"parcel_carrier_id":null,"date_postedstr":"12\/07\/2010","link":"Add","stationlink":"<a target='_blank'\n href='?option=com_coinnet&view=dealerinfo&Itemid=122&station=NV23'>NV23<\/a>"},{"id":"1631050","my_name":"CT00","my_id":"11920","other_name":"FO81","date_posted":"2010-07-13 09:49:10","check_number":null,"tracking_number":null,"notes":null,"shipped":"F","paid":"F","status":false,"amount":null,"check_number_date":null,"tracking_number_date":null,"newversion":"F","bulletin_id":null,"original_mailbox_id":null,"parcel_carrier_id":null,"date_postedstr":"7\/13\/2010","link":"Add","stationlink":"<a target='_blank'\n href='?option=com_coinnet&view=dealerinfo&Itemid=122&station=FO81'>FO81<\/a>"}],"totalrecords":75,"totalpages=>":8,"currpage":"1","userdata":null}
答案 0 :(得分:1)
我不确定你遇到的主要问题是什么。您的代码和JSON数据有一些小错误,我建议您修复。您可以尝试使用固定版本here。它适用于Chrome 11。
我修复的小问题的简短列表:
"totalpages=>":8
而不是"totalpages":8
,但由于您使用loadonce:true
参数,因此数据将被忽略。height: 'auto'
下有逗号逗号。这是语法错误,某些浏览器可以忽略它(但不能在IE中)。-1
中的值rowList
错误。你应该使用一些大整数。例如,您可以使用rowList: [5,10,20,25,30,50,100,10000]
并修复loadComplete
至jQuery("#pager1 option[value=10000]").text('All');
key:true
,id
的{{1}}属性将被忽略。jsonReader
(或任何其他正值),而不是width:1
width:0
的包含不是JSON数据。它只是对象初始化。所以你不需要双引号属性名称。colModel
或multiselect:false
mtype: 'GET'
和url
,而不是使用长url:'/index.php?option=com_coinnet&view=snap&layout=list&Itemid=123&format=json&ajax=1'
参数url:'/index.php'
。 URL的构造方式相同,但您可以肯定,如果需要,可以在参数值中包含的特殊字符(包括空白等)将被正确编码。以下是修改版本的代码:
postData: {option:"com_coinnet", view:"snap", layout:"list", Itemid:123, format:"json", ajax:1 }
答案 1 :(得分:0)
我明白了。从最初的问题中可以找到答案:
6)登台服务器上的PHP 5.1,本地上的PHP 5.3
在PHP 5.1中没有正确转义的数据库的某个字段中存在无效字符(显示为 ),但是在PHP 5.3中。
我称这是一个Chrome错误,因为Firefox处理得很好,Chrome应该至少生成一个警告(它不会导致页面崩溃,或者崩溃javascript,或任何类似的东西)。但是,jqGrid本身可能会抑制警告。