简体   繁体   English

每当页面加载时间过长时,显示加载的Gif动画

[英]show loading Gif animation whenever page gets time too load

How can I show a loading Gif animation by using a jquery in asp.net project in Main.Master page? 如何在Main.Master页面的asp.net项目中使用jquery显示正在加载的Gif动画? Whenever its taking time, I would like to show this Gif. 每当花费时间时,我都想展示此Gif。

I searched on internet but they are showing this loading images for one control only. 我在互联网上进行搜索,但他们仅显示此加载图像仅用于一个控件。 Thats why i need to keep this jquery at one place (ie: in master page) and want too use it on all content page whenever its taking too much time to load the page (either first time the page loads or button clicked or any event taking time) 这就是为什么我需要将这个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();
            });
        });

I used this code but it is not working 我使用了此代码,但无法正常工作

You can use jQuery BlockUI plugin. 您可以使用jQuery BlockUI插件。 Here is official website, please read documentation 这是官方网站,请阅读文档

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

You can do it like this 你可以这样

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

Then you can define $loading how ever you want 然后,您可以定义$ loading您想要的方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM