我有一個jqgrid,我想用我的json填充,但我無法讓它工作。我認爲我的JSON沒問題,因爲當將json作爲字符串提供時,網格工作正常(數據類型:jsonstring)。問題是,我沒有從jqgrid中得到任何錯誤,這使得它很難調試。無法使用jqgrid加載json數據,雖然jsonstring工作正常
這裏是我的JSON(驗證用的JSLint):
{ "total":"1", "page":"1", "records":"5", "rows": [ {"id" :"1", "cell" :["Modulex", "", "", "", ""]}, {"id" :"2", "cell" :["Lemoltech", "", "", "", ""]}, {"id" :"3", "cell" :["Isothermic", "", "", "", ""]}, {"id" :"4", "cell" :["Renova", "", "", "", ""]}, {"id" :"5", "cell" :["Natart Juvenile", "", "", "", ""]} ] }
下面是我的配置
$("#list").jqGrid({
url:'/tempajax/',
datatype: 'json',
colNames:['Nom','Adresse','Ville','Tel','Courriel'],
colModel :[
{name:'company_name', index:'company_name', width:55},
{name:'address', index:'address', width:90},
{name:'city', index:'city', width:90},
{name:'telephone', index:'telephone', width:80},
{name:'email', index:'email', width:80},
],
autowidth: true,
pager: '#pager',
rowNum:10,
viewrecords: true,
gridview: true,
height: '100%'
});
這是我在這裏的第一篇文章,所以我希望能有提供足夠的信息,你們到幫助,如果不只是問。
非常感謝您的幫助!
感謝您的輸入,但我擔心這可能不是問題,因爲它在我使用字符串變量(數據類型:jsonstring)中的JSON輸出時起作用。這是相同的JSON,它的工作原理,所以我認爲問題是與AJAX請求檢索JSON。你怎麼看? –