Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法使用jqgrid加载json数据,尽管jsonstring工作正常_Php_Jquery_Json_Jqgrid - Fatal编程技术网

Php 无法使用jqgrid加载json数据,尽管jsonstring工作正常

Php 无法使用jqgrid加载json数据,尽管jsonstring工作正常,php,jquery,json,jqgrid,Php,Jquery,Json,Jqgrid,我有一个jqgrid,我想用我的json填充它,但我无法让它工作。我认为我的json很好,因为当以字符串形式提供json(数据类型:jsonstring)时,网格正在工作。问题是,我没有从jqgrid得到任何错误,这使得调试变得很困难 以下是我的json(用jslint验证): 这是我的配置 $("#list").jqGrid({ url:'/tempajax/', datatype: 'json', colNames:['Nom','Adresse','Ville','

我有一个jqgrid,我想用我的json填充它,但我无法让它工作。我认为我的json很好,因为当以字符串形式提供json(数据类型:jsonstring)时,网格正在工作。问题是,我没有从jqgrid得到任何错误,这使得调试变得很困难

以下是我的json(用jslint验证):

这是我的配置

$("#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%'
});
这是我在这里的第一篇文章,所以我希望能提供足够的信息给你们帮助,如果不只是问的话


非常感谢你的帮助

JSON结果与配置jqGrid要使用的内容不匹配


您的jqGrid期望JSON结果包含公司名称、地址、城市、电话和电子邮件字段,但您的数据会返回id和单元格,甚至嵌套在顶部JSON结果中,该结果包含总计、页面、记录和行。不管怎样,它都不符合您的jqGrid。

我解决了我的问题,json毕竟是好的。服务器抛出404代码,尽管输出良好。这甚至阻止了jqGrid解析json。我希望这对其他人也有帮助

感谢您的输入,但我担心这可能不是问题所在,因为当我在字符串变量(数据类型:jsonstring)中使用JSON输出时,它会起作用。这是同一个JSON,它可以工作,所以我认为问题在于检索JSON的ajax请求。你怎么认为?
$("#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%'
});