jquery – 来自USGS geojson数据的jqGrid

我正在尝试阅读并在jqGrid中发布从USGS存储库中提取的一组地震GeoJSON数据.
请求被接受,但在可能满足标头元数据时显示“Uncaught SyntaxError:Unexpected token”.
$(function () {
    'use strict';
    $.extend($.jgrid.search,{multipleSearch: true,multipleGroup: true,overlay: 0});
    $('#grid').jqGrid({
        url: 'http://earthquake.usgs.gov/earthquakes/feed/geojson/2.5/week?callback=?',datatype: 'json',colModel: [
            {name: 'mag',label: 'MAGNITUDO',width: 150,jsonmap: 'properties.mag',sorttype: 'number',formatter: 'number',formatoptions: {decimalPlaces: 2}},{name: 'place',label: 'LOCALITA',jsonmap: 'properties.place'},{name: 'url',label: 'URL',jsonmap: 'properties.url'}
        ],toppager: true,gridview: true,rowList: [10,20,50,10000],rowNum: 10,jsonReader: {
            root: 'features',repeatitems: false
        },loadonce: true,ignoreCase: true,height: 'auto'
    }).jqGrid('navGrid','#grid_toppager',{add: false,edit: false,del: false})
      .jqGrid('filterToolbar',{stringResult: true,defaultSearch: 'cn',searchOnEnter: false});
    $("#grid_toppager option[value=10000]").text('All');
});

你有什么解决方案吗?
提前致谢.

解决方法

我查看了geojson的文档,我想我找到了问题的原因.似乎GeoJSON(P)使用eqfeed_callback作为回调名称(参见 here).所以我修复了jqGrid的一些选项,你习惯了以下几点:
url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week',datatype: 'jsonp',postData: '',ajaxGridOptions: { jsonp: false,jsonpCallback: 'eqfeed_callback',cache: true},

The modified demo现在可以使用并显示如下结果

更新:The modified demo使用GeoJSON的新URL和free jqGrid的新版本(4.14.1).

相关文章

1.第一步 设置响应头 header('Access-Control-Allow...
$.inArray()方法介绍 $.inArray()函数用于在数组中搜索指定的...
jquery.serializejson.min.js的妙用 关于这个jquery.seriali...
JS 将form表单数据快速转化为object对象(json对象) jaymou...
jQuery插件之jquery.spinner数字智能增减插件 参考地址:http...