【问题标题】:How to add ajax loader before it loads the data in jQuery jTable?如何在 jQuery jTable 中加载数据之前添加 ajax 加载器?
【发布时间】:2014-03-28 11:38:00
【问题描述】:

我正在使用 jQuery jTable,它在加载数据并显示一长串数据之前首先给出消息“无可用数据”。那么是否可以在后台加载数据时首先显示 Ajax 加载程序(loading.gif)?

编辑@Rex:我试过了,但不知道如何使用 jQuery jTable 成功函数来实现它。

这是我试过的代码:

$(document).on('click', '#PlayStatisticone', function (e) {
    function loadingAjax(div_id) {
        var divIdHtml = $("#"+div_id).html();
        $.ajax({
        url: '@Url.Action("_TopPlayedTracksPermissionCheck", "ReportStatistic")',
        type: 'POST',
        beforeSend: function() {
                $("#loading-image").show();
            },
        success: function (data) {
            $("#"+div_id).html(divIdHtml + msg);
            $("#loading-image").hide();


            $(function () {
                    $("#PartialViewTopPlayedTracks").load('@Url.Action("_PartialViewTopPlayedTracks", "ReportStatistic")');
            });

        },
        error: function (xhr, textStatus, exceptionThrown) {

            var json = $.parseJSON(xhr.responseText);

            if (json.Authenticated) {
                window.location.href = '/UnAuthorizedUser/UnAuthorizedUser';
            }
            else {
                window.location.href = '/UnAuthenticatedUser/UnAuthenticatedUser';
            }
        }
    });

任何建议都会很有帮助 提前致谢。

【问题讨论】:

  • @Rex 谢谢 - 我已经更新了我尝试过的代码的最终版本。它根本不起作用:(

标签: c# asp.net ajax loading jquery-jtable


【解决方案1】:

效果如我所愿...我从另一个论坛找到的

我不知道是否可以在此处发布其他论坛的工作答案:

这是有效的代码:

$(document).ready(function () {
 // DOM is ready now
 $.post("<%= Url.Action("ActionThatGetsTableOnly") %>",
    "",
    function(data) { $("#elementToReplaceId").html(); },
"html"
  );
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-07
    相关资源
    最近更新 更多