added ajax call end error handling