error checking in ajax call