show loading function for ajax


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

U must have animation image here " /images/ajax-loader.gif"


Copy this code and paste it in your HTML
  1. function show_loading(obj,where){
  2.  
  3.  
  4.  
  5. if(!$('div#loading').length){
  6.  
  7. $('body').append("<div id='loading'><img src='/images/ajax-loader.gif' /></div>")
  8.  
  9. }
  10.  
  11.  
  12.  
  13. var off = obj.offset()
  14.  
  15. left_d = off.left-18
  16.  
  17. if(where){
  18.  
  19. switch(where){
  20.  
  21. case 'left':
  22.  
  23. left_d = off.left-18
  24.  
  25. break;
  26.  
  27.  
  28.  
  29. case 'right':
  30.  
  31. left_d = off.left+obj.width()+10
  32.  
  33. break;
  34.  
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41. var csss = {
  42.  
  43. 'top':off.top,
  44.  
  45. 'left':left_d
  46.  
  47. }
  48.  
  49.  
  50.  
  51. $('div#loading').show().css(csss);
  52.  
  53. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.