Added some more error checking and loading image to indicate that a pending AJAX operation is occuring.