error handling for ajax routes