Ram Singh Ram Singh - 4 years ago 192
Javascript Question

How to show loader with set timeout function?

I have a function that is doing some calculation, i want to add jquery loader for some time for this, i have tried the following but it is not displaying the loader not getting why?

function onChangeLeaveEndDate() {
//$('.k-loading-mask').css('display', 'block !important');
$(".k-loading-mask").show();
setTimeout(function () {
test();
}, 10000);
$('.k-loading-mask').hide();
}


did id do any wrong code in above? please help me how can i show a loader for specific period of time.

Answer Source

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
try this as:

function onChangeLeaveEndDate() {
   //$('.k-loading-mask').css('display', 'block !important');
   $(".k-loading-mask").show();
   setTimeout(function () {
      test(); 
      $('.k-loading-mask').hide();
   }, 10000);
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download