updated ajax error handling