added error functions to ajax requests to catch unauthorized error