added giveup function, added isAjax function