Quit calling ajax when there is an error

Change-Id: Iceb0ab2ff2e4d8a70df50ade9e81e0662d93fb16