Showing loading animation in center of page while making a call to Action method in ASP .NET MVC

后端 未结 4 926
臣服心动
臣服心动 2020-12-04 14:44

My application makes several calls to an Action method (ASP .NET MVC) which returns a Json object. When the application is waiting for this method to return its data I want

4条回答
  •  既然无缘
    2020-12-04 15:36

    Another solution that it is similar to those already exposed here is this one. Just before the closing body tag place this html:

    
    

    Finally, replace .loader-text element's content on the fly on every navigation event and turn on the #resultloading div, note that it is initially hidden.

    var showLoader = function (text) {
        $('#resultLoading').show();
        $('#resultLoading').find('.loader-text').html(text);
    };
    
    jQuery(document).ready(function () {
        jQuery(window).on("beforeunload ", function () {
            showLoader('Loading, please wait...');
        });
    });
    

    This can be applied to any html based project with jQuery where you don't know which pages of your administration area will take too long to finish loading.

    The gif image is 176x176px but you can use any transparent gif animation, please take into account that the image size is not important as it will be maxed to 150x150px.

    Also, the function showLoader can be called on an element's click to perform an action that will further redirect the page, that is why it is provided ad an individual function. i hope this can also help anyone.

提交回复
热议问题