【问题标题】:show loading Gif animation whenever page gets time too load每当页面加载时间过长时显示加载 Gif 动画
【发布时间】:2018-01-16 12:07:45
【问题描述】:

如何在 Main.Master 页面的 asp.net 项目中使用 jquery 显示加载 Gif 动画?每当需要时间时,我都想展示这个 Gif。

我在互联网上搜索过,但他们只为一个控件显示此加载图像。这就是为什么我需要将此 jquery 保留在一个地方(即:在母版页中)并希望在所有内容页面上使用它,只要它花费太多时间来加载页面(第一次加载页面或单击按钮或任何事件)花时间)

$.ajax({
            type: "POST",
            url: "~/Jobs/ExportJobEntry.aspx",
            data: dataString,
            beforeSend: loadStart,
            complete: loadStop,
            success: function() {
                $('#form').html("<div id='msg'></div>");
                $('#msg').html("Thank you for your email. I will respond within 24 hours. Please reload the page to send another email.")
            },
            error: function() {
                $('#form').html("<div id='msg'></div>");
                $('#msg').html("Please accept my apologies. I've been unable to send your email. Reload the page to try again.")
            }
            return False);
        });
        $(document).ready(function () {
            $(document).ajaxStart(function () {
                $("#loading").show();
            }).ajaxStop(function () {
                $("#loading").hide();
            });
        });

我使用了这段代码,但它不起作用

【问题讨论】:

标签: c# asp.net


【解决方案1】:

您可以使用 jQuery BlockUI 插件。这里是官网,请阅读文档

http://malsup.com/jquery/block/

【讨论】:

    【解决方案2】:

    你可以这样做

    $(document)
      .ajaxStart(function () {
        $loading.show();
      })
      .ajaxStop(function () {
        $loading.hide();
      });
    

    然后你可以随意定义 $loading

    【讨论】:

    • 你如何使用这个,确切地说?正在加载什么?
    猜你喜欢
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 2013-04-10
    • 2018-03-31
    相关资源
    最近更新 更多