【问题标题】:load table if user click on button如果用户单击按钮,则加载表
【发布时间】:2014-08-31 12:06:44
【问题描述】:

我有带有表格的主页,目前当我运行我的项目并打开页面时,页面加载了所有可能需要一些时间的数据,我想避免它......

我在页面中有加载按钮,我希望用户点击此按钮时加载表格,而不是默认加载,

我该怎么做?

我应该如何知道用户是否单击此按钮以在索引页面中加载数据,因为当我运行项目时,索引会在之前调用

查看...

【问题讨论】:

  • 您可能需要ajax在单击按钮时加载json类型的数据然后构造html..

标签: asp.net .net asp.net-mvc asp.net-mvc-4 asp.net-mvc-5


【解决方案1】:

当按钮为clicked时,您可以将表格移动到局部视图并使用AJAX将表格加载到主视图。

示例

$( "#button" ).click(function() {
    $.ajax({
        type: "GET",
        url: "/controller/method/" /* This method should return a partial view that contains the table */
    })
    .done(function( html ) {
        $("#tabel").html(html);
    });
});

谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-02
    • 2021-12-30
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多