add some more error handling on ajax calls