javascript - jQuery Spinner does not show up before the upcoming function finished loading -
i created 2 functions should show , hide spinner (ios spinner):
    var overlay;      function startspin() {         var opts = {                 lines: 13, // number of lines draw                 length: 11, // length of each line                 width: 5, // line thickness                 radius: 17, // radius of inner circle                 corners: 1, // corner roundness (0..1)                 rotate: 0, // rotation offset                 color: '#fff', // #rgb or #rrggbb                 speed: 1, // rounds per second                 trail: 60, // afterglow percentage                 shadow: false, // whether render shadow                 hwaccel: false, // whether use hardware acceleration                 classname: 'spinner', // css class assign spinner                 zindex: 2e9, // z-index (defaults 2000000000)                 top: 'auto', // top position relative parent in px                 left: 'auto' // left position relative parent in px             };         var target = document.createelement("div");         document.body.appendchild(target);         var spinner = new spinner(opts).spin(target);         overlay = iosoverlay({             text: "searching ...",             spinner: spinner         });          return false;     }      function stopspin() {         window.settimeout(function() {             overlay.update({                 icon: "img/check.png",                 text: "success!"             });         }, 3e3);          window.settimeout(function() {             overlay.hide();         }, 5e3);     }   so in process() function first enable spinner, call function loads data database , after stop spinner:
function process() {      startspin();      loaddata();      stopspin(); }   the loaddata() function quite heavy, means can take seconds finish.
the problem spinner shows once loaddata() function finished. 
why spinner not show before loaddata() function called?
 
 
  
Comments
Post a Comment