handle ajax 401 properly and debug