Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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
Javascript 如何从AJAX响应数据呈现剑道UI网格?_Javascript_Jquery_Ajax_Kendo Ui_Kendo Grid - Fatal编程技术网

Javascript 如何从AJAX响应数据呈现剑道UI网格?

Javascript 如何从AJAX响应数据呈现剑道UI网格?,javascript,jquery,ajax,kendo-ui,kendo-grid,Javascript,Jquery,Ajax,Kendo Ui,Kendo Grid,我有一段代码,它从一个静态url获取json对象,然后呈现网格。但我想使用json数据作为AJAX响应检索,然后使用此响应文本呈现网格因为对于实际部署,我不能使用静态URL。 $("#grid").kendoGrid({ dataSource: { type: "json", transport: { read: {url: "http://url/returnsjsonobject.php"} //

我有一段代码,它从一个静态url获取json对象,然后呈现网格。但我想使用json数据作为AJAX响应检索,然后使用此响应文本呈现网格因为对于实际部署,我不能使用静态URL。

    $("#grid").kendoGrid({
    dataSource: {
        type: "json",
        transport: {
            read: {url: "http://url/returnsjsonobject.php"}
            //THIS GETS DATA FROM STATIC URL BUT I WANT TO READ DATA AS AJAX RESPONSE
            //like read: somefunctioncall
            //or like read: somevariable
        },
        schema: {
            model: {
                fields: {
                    id: {type: "string", editable: false},
                    name: {type: "string"}

                }
            }
        },
        pageSize: 20
    },
    height: 430
    columns: [
        {field: "id", title: "ID", width: "20px", hidden: "true"},
        "name",
});
提前感谢您的帮助,如果您有任何其他方法;我很乐意尝试它。

记住,它不一定是常数,但可能是一个函数:

transport: {
    read: {
        url: function(options) {
            return "somefunctionalcall?id=" + options.id,
        },
        dataType: "json"
}
transport: {
    read: function (options) {
        $.ajax({
            dataType: "json",
            url: "somefunctionalcall",
            success: function (d) {
                options.success(d);
            }
        });
    }
}
甚至定义为一个函数:

transport: {
    read: {
        url: function(options) {
            return "somefunctionalcall?id=" + options.id,
        },
        dataType: "json"
}
transport: {
    read: function (options) {
        $.ajax({
            dataType: "json",
            url: "somefunctionalcall",
            success: function (d) {
                options.success(d);
            }
        });
    }
}
记住,它不一定是常数,但可能是函数:

transport: {
    read: {
        url: function(options) {
            return "somefunctionalcall?id=" + options.id,
        },
        dataType: "json"
}
transport: {
    read: function (options) {
        $.ajax({
            dataType: "json",
            url: "somefunctionalcall",
            success: function (d) {
                options.success(d);
            }
        });
    }
}
甚至定义为一个函数:

transport: {
    read: {
        url: function(options) {
            return "somefunctionalcall?id=" + options.id,
        },
        dataType: "json"
}
transport: {
    read: function (options) {
        $.ajax({
            dataType: "json",
            url: "somefunctionalcall",
            success: function (d) {
                options.success(d);
            }
        });
    }
}