How to show jQuery is working/waiting/loading ?

Posted by Kim on Stack Overflow See other posts from Stack Overflow or by Kim
Published on 2010-05-27T08:14:06Z Indexed on 2010/05/27 8:51 UTC
Read the original article Hit count: 277

Filed under:
|
|

How do I show a loading picture and/or message to the user ? If possible, would I like to know how to make it full screen with grey-dimmed background. Kinda like when viewing the large picture from some galleries (sorry, no example link).

Currently do I add a CSS class which has the image and other formating, but its not working for some reason. Results from the search do get inserted into the div.

HTML

<div id="searchresults"></div>

CSS

div.loading {
  background-image: url('../img/loading.gif'); 
  background-position: center;
  width: 80px;
  height: 80px;
}

JS

$(document).ready(function(){
  $('#searchform').submit(function(){
    $('#searchresults').addClass('loading');
    $.post('search.php', $('#'+this.id).serialize(),function(result){
      $('#searchresults').html(result);
    });
    $('#searchresults').removeClass('loading');
    return false;
  });
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-load