【问题标题】:asp.net mvc ajax post traditional parameter serializationasp.net mvc ajax post 传统参数序列化
【发布时间】:2013-07-02 05:10:52
【问题描述】:

我正在使用 kendo-ui 的树视图。

插入新的树节点后,我需要刷新树视图。为了用户友好,我想通过为负责创建树视图的 JSON 的方法提供三个参数来使树视图自动扩展到新创建的树节点。您可以在下面查看代码。

treeview.dataSource.transport.options.read.data = {
    showInactiveItems: $("#ShowInactiveAreas").find('i').hasClass('icon-eye-close'),
    selectedAreaId: areaId,
    selectedAreaType: areaType,
    ancestry: ancestry
};
treeview.dataSource.read();

所以我打算将父 ID(祖先)数组传递给该方法,以便该方法知道将哪个扩展属性设置为 true。

如果它是一个 jQuery,我知道如何使用 jQuery.makeArray(ancestry) 并在 $.ajax() 中将传统参数序列化设置为 true。但这是剑道。

有谁知道如何让 treeview.dataSource.read() 进行传统的参数序列化?

或者如何让asp.net mvc 4.0接受ajax post参数如

ancestry[]  Indonesia
ancestry[]  Aceh

似乎 asp.net MVC 不像 PHP 那样支持参数名称中的“[]”。

【问题讨论】:

    标签: javascript jquery asp.net-mvc kendo-ui kendo-treeview


    【解决方案1】:

    看来我不能坚持发布数据。我必须使用 jQuery.param 切换方法以使用 urlencoded 参数

        treeview.dataSource.transport.options.read.data = {
                showInactiveItems: $("#ShowInactiveTerritories").find('i').hasClass('icon-eye-close'),
            selectedTerritoryId: territoryId,
            selectedTerritoryType: territoryType,
        };
        query = "?" + jQuery.param({ ancestry: ancestry }, true);
        treeview.dataSource.transport.options.read.url = loadurl + query;
        treeview.dataSource.read();
    

    成功了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-16
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 2012-09-21
      • 1970-01-01
      相关资源
      最近更新 更多