开发者

show loading.. image when processing onclick event

开发者 https://www.devze.com 2022-12-22 14:59 出处:网络
A button click event triggers filtering on a data table. While JQuery is processing that , the page should display a loading image.This is not an ajax request.

A button click event triggers filtering on a data table. While JQuery is processing that , the page should display a loading image.This is not an ajax request.

This is my code that doesn't work :

$("somebutton").click(function(){
  $("#lo开发者_StackOverflow社区ader").show();
  // do some stuff.....
  //...
  // now hide the loader again
  $("#loader").hide();
});

Any ideas?


If your do some stuff can use a callback function then put the hide loader function in that. Something like

$("somebutton").click(function(){
  $("#loader").show();
  $("yourselector").method(something, function(){$("#loader").hide();});  
});


Try this:

$("somebutton").click(function(){
  $("#loader").show();
  // do some stuff.....
  //...
  // now hide the loader again
  $("#loader").hide();
});

Use click instead of onclick

0

精彩评论

暂无评论...
验证码 换一张
取 消