ajax - use ajaxStart and ajaxStop jquery methods only for some of requests -
i use ajaxstart , ajaxstop jquery methods show , hide loading message when request send via ajax . following code :
$('<div><img src="images/searching.gif" align="absmiddle" border="0" />please wait ...</div>') .attr('id','loading') .appendto('body') .ajaxstart(function() { $(this).animate({ top : '40px', opacity : 1.0 }, 500); }) .ajaxstop( function(){ $(this).animate({ top : '-75px', opacity : 0.1 }, 500); });
but don't want loading show requests , show of specific request . have solution problem ?
separate lines of code create loader images , bind ajax events
differentiate between images require ajaxstop/ajaxstart events , don't. use css classes differentiate between images.
creating loader images ajax events:
for ajax :
$('<div><img src="images/searching.gif" align="absmiddle" border="0" />please wait ...</div>').attr('id','loading').attr('css','ajax-img').appendto('body')
which dont require ajax :
$('<div><img src="images/searching.gif" align="absmiddle" border="0" />please wait ...</div>').attr('id','loading').appendto('body')
bind ajaxstop , ajaxstart events images having 'ajax-img' class
$('img.ajax-img').ajaxstart(function() { $(this).animate({ top : '40px', opacity : 1.0 }, 500); }) .ajaxstop( function(){ $(this).animate({ top : '-75px', opacity : 0.1 }, 500); });
Comments
Post a Comment