1

使用jsGrid我正在尝试显示来自我的服务器的信息。因此,我收到数据的格式是:

{
  "Response": [
    {
      "this": "1",
      "that": 42,
      "theOtherThing": "2016-01-28T19:45:19.093Z"
    },
    {
      "this": "2",
      "that": 49,
      "theOtherThing": "2016-01-28T19:45:19.093Z"
    }
  ]
}

如何从对象响应中提取此信息,以便在我的jsGrid字段中显示它?

fields: [
            {name: 'this', type: 'text', width: 100},
            {name: 'that', type: 'number', width: 100},
            {name: 'theOtherThing', type: 'text', width: 100}
    ]
4

1 回答 1

1

所以我只需要改变我的 ajax 调用的格式:

controller: {
    loadData: function () {
        var deferred = $.Deferred();
        $.ajax({
            type: 'GET',
            url: 'ThisGoesSomewhere',
            dataType: 'json',
            success: function(res){
                deferred.resolve(res.Response);
            },
            error: function(res){
                console.log('error ' + res);
            }
        });
        return deferred.promise();
    }
}
于 2016-01-28T22:48:43.853 回答