Add error function to ajax call