O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Global Event Handlers

$(document).ajaxStart(function(){   $("form").addClass("processing"); }); $(document).ajaxComplete(function(){   $("form").removeClass("processing"); });

jQuery provides methods to create global event handlers that are called on events such as initialization or completion for all AJAX requests. The global events are fired on each AJAX request. Table 13.2 lists the methods that can be used to register global event handlers.

An example of using a global event handler to set the class of a form is shown here:

$(document).ajaxStart(function(){   $("form").addClass("processing"); }); $(document).ajaxComplete(function(){   $("form").removeClass("processing"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required