added ajax request error logic so that the users won't wait when an error happens