Ajax event refactor