Added error handling to ajax http calls.