Change cursor to wait while loading a content, after, chage cursor to default when loading content is finished.

Change cursor to wait while loading a content, after, chage cursor to default when loading content is finished.

Hi all, as the tittle says, I want to change the mouse pointer to diferent images, something like:
  1. $('#searchFor').keypress(function(e) {
  2. code= (e.keyCode ? e.keyCode : e.which); 
  3. var nombreServer = $('#searchFor').attr('value');
  4. if (code == 13) { 
  5. $(this).css('cursor','progress');
  6. $('#muestraListadoServers').load('mostrarServer.php',{sname: nombreServer});
  7. $(this).css('cursor','default');
  8. }
  9. });
Of course I know it doesn't work this way, but it is a graphic way to explain it.

I tried for example:

  1. $('#searchFor').keypress(function(e) {
  2. code= (e.keyCode ? e.keyCode : e.which); 
  3. var nombreServer = $('#searchFor').attr('value');
  4. if (code == 13) { 
  5. $('#muestraListadoServers').load('mostrarServer.php',{sname: nombreServer});
  6. $('#muestraListadoServers').ready (function() {$(this).css('cursor','progress');});
  7. }
  8. });
Thinking "When dom is loading, shows pointer like progress". But it doen't run, nothing happens.

Also I was thinking on a calling back, but I'm not sure about it is well done, because, it doesn't run, nothing happens:

  1. ...
  2. if (code == 13) { 
  3. $('#muestraListadoServers').load('mostrarServer.php',{sname: nombreServer},function() {$(this).css('cursor','progress');} );
  4. }
  5. ...

I try make a textbox like a "<a href" behaviour, changing css cursor by differents actions.

This is the full code:

  1. $().ready(function() {
  2. $('#searchFor').autocomplete({source:'printNameServers.php', minLength:2});
  3. $('#searchFor').keypress(function(e) {
  4. code= (e.keyCode ? e.keyCode : e.which); 
  5. var nombreServer = $('#searchFor').attr('value');
  6. if (code == 13) { 
  7. $('#muestraListadoServers').load('mostrarServer.php',{sname: nombreServer});
  8. }
  9. });
  10. });


I appreciate any help, thank you.