Improve Ajax error and message handling.