This example is useful for pages where ajax requests are made, here we use the
while loop it will continue to run until
ajaxIsComplete == true and so the return statement is executed.
We check that all ajax requests are complete by confirming that
jQuery.active is equal to
0. This works because each time a new ajax request is made
jQuery.active is incremented and each time a request complements it is decremented, from this we can deduce that when
jQuery.active == 0 all ajax requests must be complete.