Improved AJAX calls error handling.