added beforeAjax callbacks and ajax helper method