Return to Snippet

Revision: 37840
at December 18, 2010 01:50 by smchristensen


Updated Code
$('#loading').bind('ajaxStart', function() {
	var n = $(this);
	n.data('state', 'started');
	setTimeout(function() {
		if (n.data() && n.data().state == 'started') {
			n.slideDown(500);
		}
	}, 300);
}).bind('ajaxStop', function() {
	var n = $(this);
	n.data('state', 'stopped');
	n.slideUp(500);
});

Revision: 37839
at December 18, 2010 01:05 by smchristensen


Initial Code
$('#loading').bind('ajaxStart', function() {
	var n = $(this);
	n.data('state', 'started');
	setTimeout(function() {
		if (n.data() && n.data().state == 'started') {
			n.slideDown(300);
		}
	}, 300);
}).bind('ajaxStop', function() {
	var n = $(this);
	n.data('state', 'stopped');
	n.slideUp(300);
});

Initial URL


Initial Description
jQuery bindings for showing and hiding a div during AJAX requests.  The div will not show unless the AJAX request takes a certain amount of time (in this case 300ms).  This will reduce the flicker effect of showing and hiding throbbers.

Initial Title
Binding throbber div for jQuery AJAX requests

Initial Tags
jquery

Initial Language
jQuery