Improve error handling and error display of ajax calls