refactor ajax request callback