From the course: jQuery Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using global AJAX handlers

Using global AJAX handlers - jQuery Tutorial

From the course: jQuery Essential Training

Start my 1-month free trial

Using global AJAX handlers

- (Narrator) If you're building a web application that uses more than a trivial amount of AJAX, you might want to centralize some of the operations to make them easier to maintain and update in the future. The jQuery AJAX module provides a set of global event handlers that you can use to register functions to listen for interesting events that take place during the life cycle of all the AJAX requests on a given page. There are a number of scenarios where this approach might make sense. To take one example, you might want to centralize all of your error handling code in one place, rather than attach individual error handling functions to each one of your requests. jQuery provides an event for this purpose. Or maybe you're working with a server that requires certain custom HTTP headers to be set for every request that comes in. jQuery gives you a way to intercept every request before it goes out, so that you can do things like modify or attach information to the request. You could even…

Contents