Change cursor and prevent click on AJAX request


/ Published in: jQuery
Save to your folder(s)

I found this really useful when using AJAX that will change database. Preventing the user to re-do the action is not the best way but it still is a little unobtrusive to the user as it lets him navigate the page and know what is going on.


Copy this code and paste it in your HTML
  1. $('html').ajaxStart(function(){
  2. $(this).addClass('wait').bind('click',function(){
  3. return false;
  4. });
  5. }).ajaxStop(function(){
  6. $(this).removeClass('wait').unbind('click');
  7. });
  8.  
  9. //On the CSS
  10. html.wait, html.wait * {cursor:wait;}

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.