jQuery Tutorial
jQuery Introduction jQuery Getting Started jQuery Syntax jQuery Selectors jQuery Events
jQuery Effects
jQuery Hide/Show jQuery Fade jQuery Slide jQuery Animation jQuery stop() jQuery Callback jQuery Chaining
jQuery Manipulation
jQuery Get/Set jQuery Add jQuery Remove jQuery CSS Classes jQuery css() jQuery Dimensions
jQuery Traversing
jQuery Traversing jQuery Ancestors jQuery Descendants jQuery Siblings jQuery Filtering
jQuery AJAX
jQuery AJAX Intro jQuery Load jQuery Get/Post jQuery AJAX Events
jQuery Misc
jQuery noConflict() jQuery Filters
jQuery References
jQuery Reference jQuery Selectors jQuery Events jQuery Effects jQuery HTML/CSS jQuery Traversing jQuery AJAX jQuery Miscellaneous jQuery Properties

jQuery Ajax Events

Ajax requests produce a number of different events that you can subscribe to.


Types of Ajax Events

There are two types of Ajax events:

  • Local Events
  • Global Events

Ajax Local Events

Ajax local events are callbacks that you can subscribe to within the Ajax request object.

You can listen for ajax local events like so:

Run code

There are four Ajax local events:

  • beforeSend - A function to run before the request is sent
  • error - A function to run if the request fails
  • success - A function to be run when the request succeeds
  • complete - A function to run when the request is finished (after success and error functions)

Ajax Global Events

Ajax global events are triggered on the document, calling any handlers which may be listening.

You can listen for ajax global events like so:

Run code

There are six Ajax global events:

  • ajaxComplete() - Attach a function to be called when Ajax requests complete
  • ajaxError() - Attach a function to be called when Ajax requests complete with an error
  • ajaxSend() - Attach a function to be called before an Ajax request is sent
  • ajaxStart() - Attach a function to be called when the first Ajax request begins
  • ajaxStop() - Attach a function to be called when all Ajax requests have completed
  • ajaxSuccess() - Attach a function to be called whenever an Ajax request completes successfully

jQuery AJAX Reference

For a complete AJAX methods reference, visit our jQuery AJAX Reference.