Add error handling for failed ajax call