refactored javascript (ajax delete)