fix error handling, and ajax call error handling,