简体   繁体   中英

Fire javascript during asp.net postback (to show css loader/spinner)

I'm trying to show a CSS spinner during the asp.net postback (more specifically during a file upload to the server).

My spinner is located centralized in the master page, and inside a div named "dvProgress".

My javascript code looks like this:

    $(document).ready(function () {
        $("div[id$=dvProgress]").fadeOut(500);
    });

    $(document).ajaxStart(function () {
        $("div[id$=dvProgress]").fadeIn(100);
    });

    $(document).submit(function () {
        $("div[id$=dvProgress]").fadeIn(100);
    });

This works between pages and other things, but during an upload, for example, it doesn't work. It seems that the problem is in asp.net postbacks.

What I can do to show a spinner in these situations?

You can use AJAX file upload tools. They have inbuilt progress settings. For starter you can refer this :

http://ajaxuploader.com/default.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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