hi Richard, Thanks for your help..although I got it working but my approach definetly seems to have bug...here is what is working for me
jQuery.fn.customLoad = function(url){ $(this).ajaxStart(function(){ $(this).html("<div align=\"center\"><img src=\"/cake2/img/images/loadingAnimation.gif\" /></div>"); }); $(this).load(url); return; } your approach seems cleaner and without bug..I think I will go with yours.. Thanks On May 20, 9:50 pm, "Richard Worth" <[EMAIL PROTECTED]> wrote: > On 5/20/07, bingo <[EMAIL PROTECTED]> wrote: > > > > > > > jQuery.fn.customLoad = function(url){ > > return $(this).ajaxStart(function(){ > > $(this).html("<div align=\"center\"><img > > src=\"/cake2/img/images/ > > loadingAnimation.gif\" /></div>"); > > $(this).load(url); > > }); > > }; > > > As you can see, I am just trying over write load function so that > > whenever any div is being loaded, just attach a new div that display > > loading animation. > > Try this: > > jQuery.fn.customLoad = function(url){ > $(this).bind("ajaxStart", function(){ > $(this).html("<div align=\"center\"><img > src=\"/cake2/img/images/loadingAnimation.gif\" /></div>"); > }); > $(this).bind("ajaxStop", function(){ > $(this).unbind("ajaxStart"); > }); > return $(this).load(url); > > }; > > I found the unbind necessary to keep ajaxStart from being called a second > time after the element is loaded. I think this may be a bug. > > - Richard D. Worth