简体   繁体   中英

Change of mouse cursor too fast when saving less data

"cursor", "wait" only shows when i save many item on the database, however, if i only add one data,changing of "cursor", "wait" to "cursor", "default" doesnt not show because the process is too fast. this is how i set my cursor image : Is there anything that i can code,so the changing of cursor will be seen by the GUI user even he saved only one item(saving too fast csenario).

 $(".save").click(function() {
        $("body").css("cursor", "wait"); 
      save();
});


function save(){
           ///saving to database and other happens here
           $("body").css("cursor", "default");
           //end of saving process here
}

You can save items to database only using ajax method from javascript. So,

$( document ).ajaxStart(function() {

    $("body").css("cursor", "wait"); 

 });

$( document ).ajaxComplete(function() {
       $("body").css("cursor", "default"); 

 });

Try this code:

 $(".save").click(function() {
        $( document ).ajaxStart(function() { $("body").css("cursor", "wait"); }).ajaxComplete(function() { 
              $("body").css("cursor", "default"); 
        });

     });

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