Friday, October 12, 2012

jQuery Ajax request progress indicator events

Ajax requests are handled in 2
parts, the client makes the request to the server, processing happens at the
server and the result in sent back to the client, the client decodes the data
sent by the server and displays it in the browser.

If the processing activity at the server end is a time consuming one, the user
will not be able to guess on what is happening and how long will it take to
process the request, since the page does not post back the browser’s progress
bar will also be idle.

To provide an indication of the request under progress jquery provides 2 events
ajaxStart abd ajaxEnd, as the name indicated these events will get fired when
an Ajax request starts and when the request Ends, these events can be used to
display a loading information to the user.

The syntax for these events are as follows.

ajaxStart(function())
ajaxStop(function())

These functions are common to all the
Ajax request in the page and will get fired when any of the Ajax requests in
the page starts or Stops.