refactoring delete preference code to use ajax call instead of page reload