Fetching contributors…
Cannot retrieve contributors at this time
20 lines (17 sloc) 735 Bytes
<script>{ "title": "Ajax Events", "level": "beginner", "source": "", "attribution": [ "jQuery Fundamentals" ] }</script>

Often, you'll want to perform an operation whenever an Ajax request starts or stops, such as showing or hiding a loading indicator. Rather than defining this behavior inside every Ajax request, you can bind Ajax events to elements just like you'd bind other events. For a complete list of Ajax events, visit Ajax Events documentation on

// Setting up a loading indicator using Ajax Events
$( "#loading_indicator" )
	.ajaxStart(function() {
		$( this ).show();
	.ajaxStop(function() {
		$( this ).hide();